I have a sorted list of integers:
l = [1,2,4,5]
I want to find the next free number in that range, in this case 3
.
Are there available Python functions that can help with this? To create this manually I was thinking I would need to fetch the first and last index from l
and create a new list, l_all
, of all sequential integers inbetween those two values. Then walk and compare both lists and when a number exists in l_all
but does not exist in l
I would have my next free number. I'm curious if there is a more Pythonic way of doing this.