not sure if my title does this question justice, this is my first post, forgive me if this is answered somewhere else but I really did try researching it and trying to find the answer specific to my question.
I am very new to Python and I was building my first program, everything is working fine, except for the part of the code that asks the user if they want to know the length of their name.
I am trying to add in multiple answers for "yes" and for "no" so that if the user inputs something like "yeah" or "nope" it will still accept the answer. I built lists for possible answers. However it just skips over my if statement, my elif statement, and goes right to my else statement. I have also tried not using lists, but "and" and also "or" with no luck.
# prints the length of name if user desires, if not it goes onto ask age
print('Would you like to know the length of your name?')
answer = input()
affirmative = ['yes', 'Yes', 'yeah', 'Yeah', 'yup', 'Yup', 'y', 'Y', 'yea',
'Yea']
negative = ['No', 'no', 'Nope', 'nope', 'N', 'n', 'Nah', 'nah']
if answer == affirmative:
print('The length of your name is ' + str(int(len(myName))))
elif answer == negative:
print('Ok! Thats fine! I didn\'t want to tell you anyway!')
else:
print('Ok then.....next question')
I am using the latest version of Python. Thank-you in advance and again sorry if this was answered somewhere else.