How I can overcome an issue with conditionals in python? The issue is that it should show certain text according to certain conditional, but if the input was No, it anyway indicates the data of Yes conditional.
ans=input('R u Phil?')
if ans=='Yes' or 'yes':
print('U r',abs(years),'jahre alt')
elif ans=='No' or 'no':
print("How old r u?")
or is inclusive. So the
yes test will always pass because when
ans != 'Yes' the other condition
yes has a truthy value.
>>> bool('yes') True
You should instead test with:
if ans in ('Yes', 'yeah', 'yes'): # code elif ans in ('No', 'Nah', 'no'): # code else: # more code