how accept lowercase and uppercase for string data input in python?

Question:

ask user to enter registration type
Hi I tried to make the if condition accept the answer when the user enters it in lowercase or uppercase

reg = input("nRegistration type (single or family): ") 
Asked By: itsme

||

Answers:

reg = input("nRegistration type (single or family): ") 

if reg in ['single', 'family', 'SINGLE', 'FAMILY']:
    if reg.isupper():
        print("accepted in uppercase")
    elif reg.islower():
        print("accepted in lowercase")
else:
    print("not accepted")

working code

Answered By: YUVI_1303
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.