Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

checking if a string contains a substring python

fullstring = "StackAbuse"
substring = "tack"

if substring in fullstring:
    print("Found!")
else:
    print("Not found!")

# Output - Found!

fullstring = "StackAbuse"
substring_2 = "abuse"

if substring_2 in fullstring:
    print("Found!")
else:
    print("Not found!")

# Output - Not found! 
# (Remember this is case-sensitive)
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #checking #string #substring #python
ADD COMMENT
Topic
Name
4+9 =