Good, my doubt is probably very basic but I am not able to solve it. It basically consists of how I can add my turtle dictionary to the turtle list. I've tried with append but it tells me that turtles are not defined, any suggestions? The example is as follows:
class Galapago:
tortugas=[]
def __init__(self):
self.x= 0
self.sprite= "lo"
self.color= "bue"
tortuga={}
tortuga['sprite']= self.sprite
tortuga['x']=self.x
tortuga['color']= self.color
tortugas.append(tortuga)
alex=Galapago()
I am looking to create this list (turtles) so that I can then use its data in other functions, such as the following:
def set_pencolor(self,color):
for n in range (len(tortugas)):
if tortugas[n]['sprite']== sprite:
for m in tortugas[n]:
tortugas[n]['color']= color