>>> 'A'.isalpha()
True
>>> '1'.isalpha()
False
# Basic syntax:
any(elem in your_string for elem in elements)
# Where:
# - elements is an iterable
# - any() will return true if any of the elements in elements is in
# your_string, otherwise it returns False
# Example usage:
your_string = 'a short example string'
any(elem in your_string for elem in ['Malarkey', 23, 'amp'])
--> True # any() returns True because amp is in your_string
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print("Found!")
else:
print("Not found!")
if "blah" not in somestring:
continue
string = 'ex@mple'
if '@' in string:
return True
if '@' not in string:
return False
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
txt = "foobar"
print("foo" in txt)
any(not c.isalnum() for c in string)
str="Hello, World!"
print("World" in str) # True