Answers for "python check if text is in string"

18

python test if number in string

>>> def hasNumbers(inputString):
...     return any(char.isdigit() for char in inputString)
... 
>>> hasNumbers("I own 1 dog")
True
>>> hasNumbers("I own no dog")
False
Posted by: Guest on April-17-2020
4

if substring not in string python

>>> string = "Hello World"
>>> # Check Sub-String in String
>>> "World" in string
True
>>> # Check Sub-String not in String
>>> "World" not in string
False
Posted by: Guest on December-08-2020
0

how to check a string in if statement python

if var in ['string one', 'string two']:
    do_something()
Posted by: Guest on November-24-2020

Code answers related to "python check if text is in string"

Python Answers by Framework

Browse Popular Code Answers by Language