+ 4
Why does one method return False in one line and in another it doesn't (same method)
print(" " in string) #Program returns False if " " in string == False: # On the next line program ignores that fact and goes to else print("spaces were removed") else: print("An error occured") https://code.sololearn.com/c9c45cmGaLUY/?ref=app
4 Respuestas
+ 9
Mistake is in the if statement,
I guess you need to add "()" to give priority
if (" " in string) == False:
print("spaces were removed")
else:
print("An error occured")
+ 2
You had right idea. Thanks
0
if (" " in string) == False:
it evaluate the first expression since it is false it does not check the second one. add parentheses like above.
read about the order of evaluations in if statement.