-1

One way to check if string contains text:

text = 'somewhere over the rainbow'
keyword = 'Rainbow'

if keyword.lower() in str(text).lower():
    print 'yes, it is'

Is there a shorter way?

alphanumeric
  • 17,967
  • 64
  • 244
  • 392

1 Answers1

0

You can use the find() method:

if text.lower().find(keyword.lower()) != -1:
    print 'yes, it is'
Sanyam Mehra
  • 299
  • 2
  • 14