0
How to find a letter in a string
so i'm making a output version of hangman just as a fun project and i did test of some code that will compare an input string to another string and print yes or no if it is or not in the guess is in the string but no happen what i enter it says no. Here's my code of the function: def LetterCheck(): Guess = str(input()) if Guess == "" or Guess == " ": print("Enter a letter") else: if Guess in Word: print("yes") else: print("no")
5 Answers
+ 8
BTW you never need to say str(input()) - it's redundant. Every input is always a string. Just say input() đ
+ 4
u did not define Word in function
+ 2
global Word
in your function does it
but better make it a parameter
+ 1
oh thanks i originally did define it outside of the function i guess having multiple functions for different things while using it in both doesn't work
0
Yeah I know. it's just a habit of mine to put the type of input I want it to be so I don't get confused or something, i guess I comments also allows me to do that