I have array, which I want to validate, 2nd item of that array. There are 2 ways which comes to my mind
Check for
array
lengthif len(array) > 1: # Process for array[1]
Catch
IndexError
and process inelse
block.try: array[1] except IndexError: pass else: # Process for array[1]
Which one is better?
If you have any other option, I am ready to learn :)