python...find

453
2
Jump to solution
03-21-2020 06:50 AM
KalSsin
New Contributor III

Hi~~~

Could you give me an example of the ".find()"?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

You can experiment on your own... for example given a list of text values `find` locates the first index occurrence of a string.  Remember iterables are indexed from 0,  a value of -1 indicates it wasn't found

 a = ['wet', 'souwet', 'western']

for i in a:
    print(i.find('wet'))
    
0
3
-1

View solution in original post

2 Replies
DanPatterson_Retired
MVP Emeritus

You can experiment on your own... for example given a list of text values `find` locates the first index occurrence of a string.  Remember iterables are indexed from 0,  a value of -1 indicates it wasn't found

 a = ['wet', 'souwet', 'western']

for i in a:
    print(i.find('wet'))
    
0
3
-1
KalSsin
New Contributor III

thank you so much~~~

0 Kudos