Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Asen for Python: Getting the Index of a list

Just use index()

a = "aa bb cc"

b = "bb"

print a.index(b)

If the OP wants it to only count letters:

a = "aa bb cc"

b = "bb"

index_t = a.index(b)

real_index = index_t - a[:index_t].count('')


Viewing all articles
Browse latest Browse all 3

Trending Articles