0
Could we use strings in if-else loop?
Eg : x=str(input("Write true or false")) if x=="true": print("You typed True ") elif x=="false": print ("You typed False") else: print("Error")
3 Réponses
+ 3
Why don't u try?
Do that coding and check if it does what u want.
+ 1
all empty strings are False and all other strings are True
0
Yeah you can use strings in if else statements but in your case the program will print Error if the user enters True instead of true and that applies for False too.The str() method around input is redundant since input stringifies the user input implicitly.I know I went beyond your question but I hope you got a thing or two.