python

Python - String , Check If Word Is In string

if word in mystring: 
   print ('success')


# or


if 'seek' in 'those who seek shall find':
    print('Success!')

but keep in mind that this matches a sequence of characters, not necessarily a whole word - for example, 'word' in 'swordsmith' is True. If you only want to match whole words, you ought to use regular expressions:

https://stackoverflow.com/questions/5319922/python-check-if-word-is-in-a-string

Was this helpful?