-1

I would like to make a python file that ignores lower or uppercase for input, just the text

here is what i am working with

option = input("Admin, Member, Localhost> ")
if option =="admin" or option =="member" or option =="localhost":
    print("You chose {}".format(option))
else:
    exit()

I would like the user to be able to input the words like this "admin AdMiN or ADMIN", any suggestions?

kelvar
  • 11
  • 2

2 Answers2

1

The shortest version would be:

if option.lower() in ('admin', 'member', 'localhost'):
   ...
bereal
  • 32,519
  • 6
  • 58
  • 104
0

Use .lower() function:

if option.lower() =="admin" or option.lower() =="member" or option.lower() =="localhost":

According to the docs:

Return a copy of the string with all the cased characters 4 converted to lowercase.