+ 7

How can u ensure the case of an input function doesn't affect the output?

choice = input () if choice = "A" and the user inputs a

13th Aug 2019, 5:32 PM
Sophia Okito
Sophia Okito - avatar
8 Antworten
+ 9
As Mind To Machine 💻🕆 said U can also use .lower() or .upper() Lower() will make all the letters in lowercase and upper will make all the letters in upper case. Choice=input().lower() # A >> a if (Choice=='a'): print("...") Thanks
13th Aug 2019, 5:49 PM
Prince PS[Not_Active]
Prince PS[Not_Active] - avatar
+ 9
Convert to case of your choice, you use the built-in functions as stated above. 👆👆☝
13th Aug 2019, 5:59 PM
BlackRose Mike
BlackRose Mike - avatar
+ 5
you can use upper() or lower() methods to convert string to one case before testing
13th Aug 2019, 5:43 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
+ 5
it worked. ..Thanks alot
13th Aug 2019, 5:58 PM
Sophia Okito
Sophia Okito - avatar
+ 4
if choice == “A” or “a”:
13th Aug 2019, 5:33 PM
Brave Tea
Brave Tea - avatar
+ 4
Thanks 😊
13th Aug 2019, 5:34 PM
Sophia Okito
Sophia Okito - avatar
+ 4
i will try that now
13th Aug 2019, 5:51 PM
Sophia Okito
Sophia Okito - avatar
+ 1
welcome :)
13th Aug 2019, 5:36 PM
Brave Tea
Brave Tea - avatar