My else statement is always executing even when True. How to fix? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
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 Antwort
+ 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