How to get the nth element of a python list or a default if not available

Posted by xulochavez on Stack Overflow See other posts from Stack Overflow or by xulochavez
Published on 2010-03-22T12:17:00Z Indexed on 2010/03/22 12:21 UTC
Read the original article Hit count: 265

Filed under:
|

Hi guys

I'm looking for an equivalent in python of dictionary.get(key, default) for lists. Is there any one liner idiom to get the nth element of a list or a default value if not available?

Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about list