jeudi 21 mai 2020

I cant figure out what i did wrong in this if statement inside of and def function

Whenever i run the program and type in any of the boy commands its outputs correctly, but if i use the girl commands then it outputs with error, and is there an easier way to write this entire code.

def create_a_character():
    gender = input("What's the gender?: ")
    if gender.lower() in ['boy', 'man', 'male']:
        print("Its a boy")
    elif gender.lower() in ['girl', 'woman', 'female']:
        print ("Its a girl")
    else:
        print("error")
    create_a_character()
create_a_character()

Aucun commentaire:

Enregistrer un commentaire