Doubt nested list

0
                usuario = line_conten[1].split(":")[1]
                ip = IP
                puerto = line_conten[1].split(":")[-1]
                fecha = time.strftime("%Y%m%d%H%M%S", 
                                              time.localtime(time.time()))
                expires = line_conten[3].split(":")[-1]

                datosusuarios = [usuario, ip, puerto, fecha, expires]
                print(datosusuarios)
                listadatos = []
                *listadatos = listadatos.append(datosusuarios)*
                print(listadatos)

In the marked area is where I have the doubt that command to use to add the list "datosusuarios" within the "listadatos". Currently using the append command leaves the list empty.

    
asked by Victor Correa Ruiz 04.01.2019 в 19:01
source

1 answer

0

Greetings maybe you could do something like this:

data = []
elemento1 = "Diego"
elemento2 = "28"
elemento3 = "[email protected]"
elemento4 = "1234567890"


elemento5 = "Fernanda"
elemento6 = "27"
elemento7 = "[email protected]"
elemento8 = "9876543210"

element={}
element['nombre'] = elemento1
element['edad'] = elemento2
element['correo'] = elemento3
element['telefono'] = elemento4
data.append(element)
element['nombre'] = elemento5
element['edad'] = elemento6
element['correo'] = elemento7
element['telefono'] = elemento8
data.append(element)
print(data)

The result would be something like this:

If you look at data it is the container of all my values, element1, element2..etc .. can be values that come from an array or single (unitary) values like those of my example if it's in an array you put them in a for cycle and you add the append method like I do.

I hope you will be a guide and help .. !!

    
answered by 04.01.2019 в 20:38