+ 5
# You forgot one sex ==
sex = "F"
if (sex == "M" or sex == "m"):
print("Male")
else:
print("Female")
+ 4
if (sex == "M" or sex == "m"):
+ 2
Awesome. Now please Mark the best answer and update your title to [Solved] Why the print is male
+ 2
Yarik Yaroo Python is using boolean logic. It saw "F" as a string and "m" as a string so the boolean value was true. So it prints male. If you type or 0, it will print female. Because sex is = to "M" and a string but not = to a number, according to your code.
+ 1
Yarik Yaroo
you can also use:
if sex in ("M", "m"):
print("Male")
else:
print("Female")
+ 1
C#
0
Yarik Yaroo What glitch?
0
So gyes did you explain