Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> ["foo","bar","baz"].index('bar')
- >>> help(["foo", "bar", "baz"])
- Help on list object:
- class list(object)
- ...
- |
- | index(...)
- | L.index(value, [start, [stop]]) -> integer -- return first index of value
- |
- def all_indices(value, qlist):
- indices = []
- idx = -1
- while 1:
- try:
- idx = qlist.index(value, idx+1)
- indices.append(idx)
- except ValueError:
- break
- return indices
- all_indices("foo", ["foo","bar","baz","foo"])
Add Comment
Please, Sign In to add comment