append element of list using python -


this question has answer here:

i want append element single object in list, object appends elements of list.

class a:    list_of_b=[]  class b:    name = ""  list_a = [a() in range(3)] list_b = [b() j in range(7)]  list_b[0] = "1" list_b[1] = "2" list_b[2] = "3"  list_a[2].list_of_b.append(list_b[1]) 

my problem element list_b[1] appends element in list_a not element lista_a[2].

list_of_b class variable, change instance variable

class a:     def __init__(self):         self.list_of_b = [] 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -