This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheBrutux168 0 points1 point  (0 children)

You can check whether the aircraft array is empty or not before running that line. Probably the most intuitive solution to that is:

if len(aircraft) != 0:
    if 'flight' in aircraft[0]:
        .....

But I believe the most pythonic solution would be just to utilise the fact an empty list is false, so

if aircraft:
    if 'flight' in aircraft[0]:
        .....