In Python, how can I simply do the equivalent of dictionary.get(key, default) for lists – i.e., how can I simply get the nth element of a list, or a default value if not available?
For example, given a list myList, how can I get 5 if myList is empty, or myList[0] otherwise?
To support negative indices we can use: