Answers for "python if string contains char"

10

python check if string in string

if "blah" not in somestring: 
    continue
Posted by: Guest on July-23-2020
3

python if string contains char

myString = "<text contains this>"
myOtherString = "AnotherString"

# Casting to string is not needed but it's good practice
# to check for errors 

if str(myString) in str(myOtherString): 
    # Do Something
else:
	# myOtherString didn't contain myString
Posted by: Guest on October-01-2020
0

python check character exists in string

string = 'ex@mple'

if '@' in string:
	return True

if '@' not in string:
	return False
Posted by: Guest on June-16-2021

Code answers related to "python if string contains char"

Python Answers by Framework

Browse Popular Code Answers by Language