When "Python" is detected in the text (or not) it outputs either True or False. Now i want to take those and use them to print different statements like "is there" or "is not" but i doesn't work.
Text = "Python for beginners"
print("Python" in Text)
if Text == True:
print("Its there!")
else:
print("its not there")
The problem is probably with the if Text == True: statement but I just cant get it right.
I already tried if Text is True: and if Text == "True":however nothing worked. So if someone here could help me out id be really happy
You have the right check in your print statement "Python" in text, you just don't use it in the right way. You can either store the value in a variable:
is_found = "Python" in text
if is_found:
print("Its there!")
else:
print("its not there")
or use it directly in the conditional:
if "Python" in text:
print("Its there!")
else:
print("its not there")
but by just printing the value, you are unable to access the value later in your conditional without repeating the same check.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With