In Ruby (on Rails, actually), I have the try function:
[].try(:[], 1) # => nil
[10].try(:[], 1) # => nil
[10, 20].try(:[], 1) # => 20
[10, 20, 30].try(:[], 1) # => 20
{}.try(:foo) # => nil
{ foo: 'bar' }.try(:foo) # => 'bar'
The function basically is a shortcut to avoid ifs to check if the position is present.
Is there something similar in Python?