What is the syntax to see if a string contains a value?

<string name>.find(<str>, <beg>, <end>)
#str - the search value to search <string name> with
#beg - starting index of search, default is 0
#end - ending index, default is string length

#if str found, returns index that it was found
#if str not found, returns -1
#example
str = 'HELLO WORLD'
print(str.find("ELLO"))
print(str.find("WORLD", 6,10))
print(str.find("WORLD", 6,11))

#output
1
-1
6

 

 

Advertisements