Say I generate a list from 0 – 10:
range(10)
Then I have a list of dictionaries, that look something like this:
item = [{'position': 0}, {'position': 4}]
How can I get the lowest number that is in the range that is not in position? For example, if I ask it for the next available position, it should return 1; and, having added it to the list, then 2, etc, until it hits 4, in which case it should return 5.
You find all position values
(x['position'] for x in item)),convert this list to set, substract it from the set of all numbers from 0 to maximum,
and then find minimum in the resulting set.