+ 1

When I should implement string.index() and where I should implemend string.find() method ?

Both index and string method is returning the same value. string = 'hello world' print(string.index('wo')) print(string.find('wo'))

5th Jun 2021, 6:20 AM
lisa
1 Resposta
+ 2
well i guess it is up to u which one u prefer..both do the same thing..the only difference is find() will return -1 if it fails to find ,but index() will raise an exception
5th Jun 2021, 6:26 AM
durian
durian - avatar