Let's say
>>> a = [1,2,3,4,5]
And I want an output like
>>> b
[[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5]]
Here is my code:
class Child(object):
    def get_lines(self):
        a = [1,2,3,4,5]              
        b=[]
        c=[]
        j=0
        for i in a:
            print i
            b.append(i)
            print b
            c.insert(j,b)
            j=j+1
        print c
son= Child()
son.get_lines()
When I print list b in loop, it gives:
1 
[1] 
2 
[1, 2]
3  
[1, 2, 3]  
4  
[1, 2, 3, 4] 
5 
[1, 2, 3, 4, 5]
and the output is:
[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]
Where do I make wrong in the code?
 
     
     
     
     
    