>>100269352
for such a small function it doesn't matter much if you do it one way or another in terms of prettyness, but in terms of efficiency your code is O(nlogn) because of sorting, this could be done in linear time by for example finding lowest element and second lowest element, get their difference, then make a set of the input list (pythons sets are hash sets so insertion and element access are constant time), then do a for loop over range(min(list),max(list),step) and for each iterator value check whether it's in the list
would look like this:
def missing_no(l):
s = set(l)
smallest = min(s)
s.remove(s)
next_smallest = min(s)
step = next_smallest-smallest
for i in range(next_smallest, max(s), step):
if i not in s:
return i
[\code]
also for the range function, if you give it 3 arguments like you have in your code then the arguments are first element, last element, step, you can also give it 2 arguments which gives step the default value 1 or you can give it one argument which also gives the first element the default value 0 so range(0,n,1) is the same as range(n)
and if you care about that then you might want some error handling on bad inputs like full sequences or empty lists, those don't return anything/give exception in the current code but if you know where the input comes from and it's definitely well formed I wouldn't add extra bloat for checking that