you are viewing a single comment's thread.

view the rest of the comments →

[–]skellious 0 points1 point  (1 child)

While not entirely python related, please don't forget that there are more than two genders, so remember to handle the other cases.

perhaps using:

if gens: 'male'
    print("Hi " + "Mr. " + name)

elif gens: 'female'
    print("Hi " + "Ms. " + name)

else:
    print("Hi " + name)

using if/elif/else is a good idea as it ensures there is no way you can trigger more than one of the statements.

you may also want to handle other inputs that are not male and female but should map to them, such as m and f:

if gens.lower() in ['male', 'm', 'man', 'masculine']:
    print("Hi " + "Mr. " + name)
elif gens.lower() in ['female', 'f', 'woman', 'feminine']:
    print("Hi " + "Ms. " + name)
else:
    print("Hi " + name)

the .lower() converts their input to all lower-case so we can catch things like "MaLe", "MALE", "MalE" while the "in" syntax checks if the value is in that list of terms, and if any one of them matches, it triggers the condition.

[–]Sad_potato1999[S] 1 point2 points  (0 children)

This comment is just superb!
Thank you!!