79471181

Date: 2025-02-26 22:46:02
Score: 1
Natty:
Report link

Create a custom function like so:

def get_element(object, index, fallback):
    try:
        return object[index]
    except IndexError:
        return fallback

Then, you call:

get_element(foo_val, 3, None)

And if 3 is in range, it returns the correct value; if not, it returns None.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Temerold