[Solved] How to catch specific index error in Python and attach new value for this? [closed]

There must be a more elegant answer to that but you can do : def extract_values(values): try: first = values[0] except IndexError: first = None try: second = values[1] except IndexError: second = None try: third = values[3] except IndexError: third = None return first, second, third 2 solved How to catch specific index error … Read more