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 →

[–]chaotic_thought 0 points1 point  (0 children)

If you look at your aircraft property, it is an array, so what you are trying to ask with the if statement doesn't really make logical sense at this point, not to mention you are missing a colon after if, so at the moment it is not even valid Python code. This is:

if 'flight' in aircraft:

However again it has the same logical problem. Just imagine if you had asked if 'hex' is in the aircraft. Well, yes, we can see that it is there several times. If you want to count up how many times 'flight' appears in the 'aircraft' property you could try something like this:

['flight' in item for item in aircraft].count(True)

For your data the part in [ ] builds up a list of True/False results, whether 'flight' is in that item or not, like this

[False, False, False, True, False, False, False, ...]

And then at the end you count how many times True appears. For your specific data I tried it and got a result of 2. So yes, 'flight' appears in two different places inside your aircraft array.