Checking if a String Contains a Substring

PHOTO EMBED

Tue Nov 07 2023 17:14:10 GMT+0000 (Coordinated Universal Time)

Saved by @knguyencookie

my_string = "Hello, World!"

if "World" in my_string:
    print("Substring found!")
else:
    print("Substring not found!")
content_copyCOPY

https://medium.com/@hannanmentor/pythons-best-code-snippets-c34ed1f07239