I am doing a fitness program in Python and I need to collect information about the user. The rest of the code works fine except when collecting gender. I want the code to repeat th
Solution 1:
This is the right approach:
while gender not in("M","F","m","f"):
when you check or "m", "m" is True as it has value in the string and therefore it will always be true.
You also could do :
while gender != "M" or gender != "F" or gender != "m" or gender != "f":
Share
Post a Comment
for "Python Loop - Continue Asking Until Correct Answer Is Inputted"
Post a Comment for "Python Loop - Continue Asking Until Correct Answer Is Inputted"