I'm a total newbie learning Python and I'm making a small text-based Fallout clone. However, I'm having issues with one set of code:
def PCgender():
gender = input("Is your character male or female? \n")
gender = gender.lower()
gender = str(gender)
if gender=="male":
print("Atta, cowboy! ")
elif gender=="female":
print("You go, girl! ")
else:
#Triple quotes here because there's both single and double quotes in this sentence and to make it go over multiple lines.
print("""Aw, you special snowflake, you! But I'm fraid I haven't coded for anything
except "male" and "female", so please try one of those! """)
PCgender()
PCgender()
Even when the input is male or female, it still returns the else function. I have a very similar block further up which works perfectly, but this doesn't and I have no idea why.
Update: I tried commenting out all of this code, but VS still ran it, so I restarted the program. Same problem. I made a new file, copied it over. Still ran the code as if it wasn't commented out. As per some nice people's suggestions, I tried running print(repr(gender) and it returned 'male'. Strange.
I then decided to remove the .lower() function and it worked! When I re-added it, it kept working, so IDK what I did wrong. The original code is up there, so please tell me what I did wrong, if you know!
Cheers!