While trying to learn Python with the online course at university of waterloo link here the rest follows:
I am trying to write a function which will consume a string, and if the first letter is equal to 'y' or 'Y', it will have a "True" boolean return. Else, it will be have a "False" output. This is my code:
def is_yes(x):
if (x[0] == 'Y' or 'y'):
return True
else:
return False
is_yes('yes')
The function has no errors and the only output is: [Finished in 0.1s]
while testing the code with adding a print()
to the function call: print(is_yes('yes'))
, no matter what the input, the answer is always True.
what is wrong with the code? Also, I'm trying to self-learn and there is no one to teach me, so I Hope I do not get banned because I ask stupid questions, I am just trying to learn.