Search substring in string

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
string = 'Hi there' # True example
string = 'Good bye' # False example
if string.find('Hi') != -1:
print 'Success!'
# Better:
string = 'Hi there' # True example
string = 'Good bye' # False example
if 'Hi' in string:
print 'Success!'