0

User input

Does anyone know where I insert a .upper() in a Python program in order for it to not matter if an input is typed in upper or lower case?

21st Jul 2019, 5:45 PM
Joshua S.
Joshua S. - avatar
2 Respostas
+ 1
Well the string you’re looking for would have to be upper case as well, for example: answer = "car" guess = str(input("what has 4 wheels and an engine? ")).upper() if guess.upper() == answer.upper(): print("correct") else: print("wrong") now the user can enter “car” in any case (car, CaR, CAR..etc) and would return correct
21st Jul 2019, 6:18 PM
Jake
Jake - avatar
0
var = input().upper() the string assigned to var will contain upper case letters
21st Jul 2019, 6:07 PM
Aravind Shetty
Aravind Shetty - avatar