def findFirstUnique(lst):
# Write your code here
for x in lst:
print ('x is:{} '.format(x))
lst.remove(x)
print lst
if x not in lst:
return x
print ('final output is : {}'.format(findFirstUnique(lst)))
Apparently it seems to go through for certain cases like this: [9, 2, 3, 2, 6, 6, 9]
And for some other cases, the for loop seems to behave so weirdly: [4, 5, 1, 2, 0, 4]
and the output for the second case :
x is:4 [5, 1, 2, 0, 4]
x is:1 >>> Why is it not picking "5" as the next value?? [5, 2, 0, 4] final output is : 1
I am kinda losing it now that I am not able to understand this for loop! Any help would be appreciated.
l = [1, 2, 3, 4, 5]; for n in l: l.remove(n)