0

My else statement is always executing even when True. How to fix?

print('Guess a letter!') a = True def checkGuess(): guess = input().lower() if guess == True: print ('Correct! You win!') else: print ('Wrong') [checkGuess() for _ in range(0,3)] while checkGuess == True: break

14th Jul 2017, 5:08 PM
Iris Eye
Iris Eye - avatar
1 Answer
+ 3
You're comparing a String to a Boolean. Convert the String to a Boolean or compare the input to a String. Example/ guess = bool(input()) OR if guess == 'True' (In this case you will still need to remove .lower())
14th Jul 2017, 5:20 PM
Rrestoring faith
Rrestoring faith - avatar