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
The logic for your if statements should be the following:
print Dr + name if title is doctor
print Mr + name if title is male
print Ms + name if title is female
These three statements are parallel to each other, so there shouldn't be a nested if statement in the first place. I suggest you read up on the if - elif - else statement in python
if title == "doctor":
print(doctor)
elif title == "male":
print(male)
else:
print(female)
If you want nested if-statements, then you need to change your logic. Here is one example.
if title is not doctor
a) check if title is male and print male
b) print female (since if title is not doctor or male, it has to be female. unless you are allowing invalid input)
else print doctor
if title != "doctor":
if title == "male":
print(male)
else:
print(female)
else:
print(doctor)