I have been typing this code and the answer I came out with is it is a fish if I type in no
z=input('Does the creature have gills? ')
if z==('yes') or ('yeah'):
print ('It is a fish!')
elif z=='no':
print('The creature is not a fish.')
I have been typing this code and the answer I came out with is it is a fish if I type in no
z=input('Does the creature have gills? ')
if z==('yes') or ('yeah'):
print ('It is a fish!')
elif z=='no':
print('The creature is not a fish.')
if z == 'yes' or ('yeah')
is equivalent to if (z == 'yes') or ('yeah')
means if the input is 'yes' or TRUE, which always evaluate to true.
what you need to do instead is if (z == 'yes') or (z == 'yeah')
Or you can just remove the parentheses
z = input('Does the creature have gills? ')
if z == 'yes' or z == 'yeah':
print('It is a fish!')
elif z == 'no':
print('The creature is not a fish.')
Some other things you can do is to make an array of the values that you want to validate, and check if a value exists
Or you can create a dictionary with the values as the key, then check if the dictionary has the value exists as a key
But a simple if statement should be enough for now.