0

How to write this line properly? (If)

if N==true or n==true or NO=true or No==true you have to write it like that? Or can you do something like if N, n, NO, No == true thanks in advance for answers

24th Jun 2017, 3:21 PM
Diego Mastro
Diego Mastro - avatar
1 Answer
+ 1
the first way, but there is probably an easier way. I assume this is a "would you like to try again" type of input? if it is, and you have a variable such as again=input() And one of n, N, No, no was input, you could handle it with a simpler if statement. if again[0].lower() == "n": This would take the first letter that is input again[0] then it would make it lower case .lower() then it would simply check if the first letter that was input was "n" here is an example- again=input("Like to play again") if again[0].lower() == "n": print("no more") else: print("Yes more") Also, true and false in Python have capital T and F. True and False. checking with or will work, but there are other ways. if you wanted specifics instead of just first letter confirmation, you could use a list. options=["n","N","No","no","NO"] again=input("Play again?") if again in options: //play again
24th Jun 2017, 3:38 PM
LordHill
LordHill - avatar