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?
2 Answers
+ 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
0
var = input().upper()
the string assigned to var will contain upper case letters