message = 'Python is a fun language to program with'
# check the index of 'fun'
print(message.find('fun'))
# Output: 12
The find() method returns the index of first occurrence of the substring
(if found). If not found, it returns -1.
message = 'Python is a fun programming language'
# check the index of 'fun'
print(message.find('fun'))
# Output: 12
search_text = 'man'
str = 'You are good man.'
if search_text in str:
print(f'Found "{search_text}" in string')
else:
print('Not found')
string.find(substring)