I am writing a helper function for flattening lists where i just remove the extra outer lists surrounding an integer:
def rem_list(a):
    if type(a) != list:
        print a,"about to return"
        return a
    else:
        rem_list(a[0])
a = []
lis2 = [2,4,[[2]],[[[1]]], 5, 6, [7]]
for each in lis2:
    a.append(rem_list(each))
print a
I am getting the output as follows:
2 about to return
4 about to return
2 about to return
1 about to return
5 about to return
6 about to return
7 about to return
[2, 4, None, None, 5, 6, None]
I do not understand this. I am returning an integer in each iteration to rem_list() but its returning None when there are outer lists present around the character. I have also included a print statement which checks exactly what I am about to return and it outputs correctly in the print but still returns None. Plz help.
 
    