Skip to content

Instantly share code, notes, and snippets.

@KeronCyst
Last active September 24, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KeronCyst/2661acaa0abfba436cfd127ecadc7d1a to your computer and use it in GitHub Desktop.
Save KeronCyst/2661acaa0abfba436cfd127ecadc7d1a to your computer and use it in GitHub Desktop.
Hangman Draft
fully_correct_guess = False
acceptable_letters = string.ascii_letters
print("Welcome to Hangman!")
while True:
word = input("What word do you want the other player to guess? ")
# make word capital and figure out how to hide the inputted word from the console
if acceptable_letters not in word: # This isn't being used right lol.
print("You can only use the standard 26 letters of the English alphabet. Try again.")
else:
break
while True:
guesses_left = input("How many guesses should this word yield? (Usually the number of its letters + 0 to 3 works.)")
if guesses_left != int(guesses_left): # Gotta look up how to correctly do this
print("Sorry, this needs to be one whole number.")
elif guesses_left > (len(word) + 3):
print("Don't be so generous! Pick a slightly lower number.")
elif guesses_left < len(word):
while True:
confirm = input("Are you SURE you want to allow so few guesses? This may make it tough. y/n") # Actually a word like REGULATIONS should have only 5-7 guesses... redo this
if confirm == "y" or confirm == "Y":
print("All right, your guesser's wrath is on you!")
break
elif confirm == "n" or confirm == "N":
print("That's what I thought. Give 'em a chance!")
else:
print('Ya gotta gimme a "y" or n" here.')
else:
print("You got it.")
break
original_guess_count = guesses_left
unsolved_letter = "_ "
guessing_progress = unsolved_letter*len(word) + str("/ ") + guesses_left # check that this actually works first
print("All right. Let's get started!")
while guesses_left > 0:
while fully_correct_guess == False:
if guesses_left > 1:
print(guessing_progress + str(" guesses. Go for it!"))
else:
print(guessing_progress + str(" guess left. Choose carefully!"))
guessed_letter = input("Guess a letter: ")
# make guessed letter capital or only allow capital, prevent non-alphabetical characters
while True:
if guessed_letter in acceptable_letters:
break
else:
print("You need to enter just one common letter.")
if input == # one letter alone
for each_letter in len(word):
if guessed_letter == len(word):
print("Good going!")
print(str(guessed_letter)) # Need to make it remember already guessed letters
else:
print(str(unsolved_letter)) # This doesn't work due to not accounting for correct letters, i think
guesses_left -= 1
if guesses_left == 1:
print("Nope. This is your last shot. Make it count!")
elif guesses_left > 1:
print("Nope. Try again. You have " + guesses_left + " guesses remaining.")
else
print("Game over. You used up all of your " + str(original_guess_count) + " guesses trying to uncover: " + str(word))
# Need to figure out how to mark fully_correct_guess as True!
print("You won! You discovered the word " + str(word) + " in " str(original_guess_count - guesses_left) + " out of " + str(original_guess_count) + " guesses.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment