python - for c in string is there a way to find position of c -


the python "for c in string" idiom might check , find need pass section of string function.

so example

str = "i <token>" ch in str:     if ch == '<':        # need know in string 

is there way way? or sort of thing should being doing different way?

>>> i, ch in enumerate(str):         print i, ch  print  0 1  2 ... 

you should careful while using str variable name that's name of built-in type.


Comments