Defining names in python

后端 未结 3 706
借酒劲吻你
借酒劲吻你 2021-01-21 17:38

I am confused on why my program is not working. I am supposed to use nested ifs to ask people their name and title(doctor, female, male) and then print out either Ms. name Mr. n

3条回答
  •  时光说笑
    2021-01-21 18:09

    You much more careful:

    name = input("Enter your name : ")
    title = input("Enter your title (doctor, female, male) : ")
    
    female = ("Ms.")
    doctor = ("Dr.")
    male = ("Mr.")
    
    if title == "doctor":                                                                                                                                                                                                                                                
        if title != "male":
            print(doctor)
        else:
            print(male)
    else:
        print(female)
    

    if and else should be in the same line

提交回复
热议问题