Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chars = #some list
- try:
- indx = chars.index(chars)
- except ValueError:
- #doSomething
- else:
- #doSomethingElse
- chars = #some list
- indx = chars.index(chars)
- if indx == -1:
- #doSomething
- else:
- #doSomethingElse
- if element in mylist:
- index = mylist.index(element)
- # ... do something
- else:
- # ... do something else
- d = dict((x, loc) for (loc,x) in enumerate(chars))
- ...
- index = d.get(chars_to_find, -1) # Second argument is default if not found.
Add Comment
Please, Sign In to add comment