Given a nested list of integers, implement an iterator to flatten it. Each
element is either an integer, or a list -- whose elements may also be integers
or other lists. For example, if the input is [[1,1],2,[1,1]], then the output
is [1, 1, 2, 1, 1]. If the input is [1,[4,[6]]], then the output is [1, 4, 6].
Would anyone be able to advise me as to where the code below went wrong? I am just starting out with python.
def eb34(list1):
   
    flat_list = []
    
    for i in range(len(list1)):
        if type(list[i]) == list:
            flat_list += flatten(list1[i])
        else:
            flat_list.append(list1[i])
        
    return flat_list
 
     
     
     
     
     
    