I'm trying to make a hangman game. I want to check if the user's guess of a letter is in the word but I'm getting an error saying
TypeError: 'in <string>' requires string as left operand, not builtin_function_or_method
I'm not sure what I'm doing wrong as I thought 'input' should always return a string unless otherwise stated.
Here's my code:
def pick_word():
word = random.choice(words)
for letter in range(len(word)):
print("_ ", end = '')
print(word)
guess = input("\n \n Guess a letter: ").lower
if guess in word:
print("Well done!")
else:
print("{} isn't in this word. Try again.".format(guess))
Thanks for your time! :)
Aucun commentaire:
Enregistrer un commentaire