0

How to make answer upper and lowercase on python

If asking a question in python, for example, user_question = input(“What data type is True?”) print(user_question) if user_question == “Boolean” print(“Correct”) How would I make it so even if user puts lowercase it would still be right. Would I use .lower() for the print statement?

26th Oct 2021, 1:44 AM
DeezPython
DeezPython - avatar
2 Antworten
+ 7
.lower() makes all letters lower case .upper() makes all letters upper case .title() makes the first letter upper case & the rest lower case This link is handy to show string methods https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_ref_string.asp
26th Oct 2021, 1:50 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 6
Not for the print statement but for the if condition: if user_question.lower() == "boolean":
26th Oct 2021, 2:03 AM
Simon Sauter
Simon Sauter - avatar