Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
# You forgot one sex == sex = "F" if (sex == "M" or sex == "m"): print("Male") else: print("Female")
12th Jun 2022, 4:49 PM
Lisa
Lisa - avatar
+ 4
if (sex == "M" or sex == "m"):
12th Jun 2022, 4:50 PM
JaScript
JaScript - avatar
+ 2
Awesome. Now please Mark the best answer and update your title to [Solved] Why the print is male
12th Jun 2022, 6:01 PM
Chris Coder
Chris Coder - avatar
+ 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.
13th Jun 2022, 4:33 PM
Chris Coder
Chris Coder - avatar
+ 1
Yarik Yaroo you can also use: if sex in ("M", "m"): print("Male") else: print("Female")
13th Jun 2022, 1:55 PM
Bob_Li
Bob_Li - avatar
+ 1
C#
14th Jun 2022, 2:45 AM
Sumit Thakur
Sumit Thakur - avatar
0
Yarik Yaroo What glitch?
13th Jun 2022, 3:54 PM
Chris Coder
Chris Coder - avatar
0
So gyes did you explain
14th Jun 2022, 2:48 AM
Sumit Thakur
Sumit Thakur - avatar
0
Researchers in the United States have made significant progress in making it simpler for authorities to identify offenders using fingerprints. https://www.bookwritingbureau.com/book-printing/
14th Jun 2022, 10:11 AM
David Christain