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






String search: search for position

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

1.Find substring in a string