String search: search for position : String find « String « Python
- Python
- String
- String find
String search: search for position

S = 'xxxxSPAMxxxxSPAMxxxx'
where = S.find('SPAM') # search for position
print where
S = S[:where] + 'EGGS' + S[(where+4):]
print S
Related examples in the same category