""" Purpose: demonstrate string method find(). """ # Initialize strings s = "can anyone" t = "an" # Find occurrences i1 = s.find( t ) i2 = s.find( t, i1 + 1 ) # start looking for next occurrence right after i3 = s.find( t, i2 + 1 ) # where the previous occurrence started # Print results print( "s:", s ) print( " ==========" ) print( " 0123456789 <== indices into s" ) print() print( "t:", t ) print() print( "s.find( t ):", i1 ) print( "s.find( t,", i1, "):", i2 ) print( "s.find( t,", i2, "):", i3 )