I have the following code:
lista_cosas=[]
class cosa():
global lista_cosas
def __init__(self,color):
self.color=color
def operacion(self):
if self.color=="verde":
lista_cosas.append(cosa("azul"))
else:
lista_cosas.append(cosa("verde"))
c=cosa("verde")
lista_cosas.append(c)
n=0
while n<10:
n+=1
for cosa in lista_cosas:
cosa.operacion()
and it gives me the following error:
Traceback (most recent call last):
File "C:/Users/elster/Desktop/Cancer modelling with python/recursive_test.py", line 21, in <module>
cosa.operacion()
File "C:/Users/elster/Desktop/Cancer modelling with python/recursive_test.py", line 9, in operacion
lista_cosas.append(cosa("azul"))
TypeError: 'cosa' object is not callable
I'm using Python 3, what I am doing wrong?