Creating Loop Objects

1
class linha ():
    def __init__ (self, texto):
        self.texto = texto
def criador ():
    for i in range(5):
        a = raw_input ('escreva: ')
        global objetoi
        objetoi = linha (a)

How do I get the criador function to generate a different object for each loop in the for loop?

    
asked by anonymous 04.05.2014 / 04:51

1 answer

1

Place within a list:

class linha ():
    def __init__ (self, texto):
        self.texto = texto
def criador ():
    lista = []
    for i in range(5):
        a = raw_input ('escreva: ')
        lista.append(linha(a))
    
04.05.2014 / 05:06