0
Noob sanitycheck [String comparison]
My testing for string equality within a function is always returning true despite meeting other conditions https://code.sololearn.com/cc5Qhh0SW7eF/?ref=app
3 odpowiedzi
+ 3
Your condition is wrong.
if "y" or "Y" == sc:
This is always True because "y" is evaluated as True (non-empty string).
To fix it use another comparison operator like:
if "y" == sc or "Y" == sc:
or you can simplify like this:
if sc in "yY":
+ 4
if "y" or "Y"== enable_spaces:
should be
if "y" == enable_spaces or "Y" == enable_spaces:
or if you are willing to lowercase before checking,
if enable_spaces.lower() == "y":
+ 3
I'm starting to see now thank you :) I like some of the option- I guess I forgot to be explicit with the if statement