🚀 Get 25% off access to all my premium courses - use discount code FUNCMAIN at checkout - view the pricing page now!

Check String Contains Python Image Check String Contains Python

In this code snippet, we are going to look at how you can check if a string exists within a string in Python.

>>> planets = "my very excellent mother just served us nine pizzas"
>>> "very" in planets
True
>>> "venus" in planets
False

We can then use this in if statements like so:

planets = "my very excellent mother just served us nine pizzas"
if "just" in planets:
    print("Just is in the mnemonic")