Back
Look at the following code.
How might I advise Python to check the beneath for the letter x and afterward print "Yes"? The beneath is the thing that I have up until now...
dog = "xdasds" if "x" is in dog: print "Yes!"
dog = "xdasds"
if "x" is in dog:
print "Yes!"
We can use in keyword
if "x" in dog: print "Yes!"
if "x" in dog:
Even if you want to check the character which is not existing in the string, you can use not in:
if "x" not in dog: print "No!"
if "x" not in dog:
print "No!"
Want to learn more about Python? Come and Join: Python course
30.9k questions
32.9k answers
500 comments
665 users