Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
nested for loops in a for loop, print each to new file

I'm trying to do something I'm sure is simple. But I'm a bit baffled.

I have 3 for loops, each time the for loops runs it takes a certain piece of data from the next document in the database. So if I change LastWrite_Time['result'][:1] to LastWrite_Time['result'][:2] then I get the date string from the first 2 documents in the directory.

I want to print the LastWrite_Time, DeltaTimeBetweenPoints, Data together for the first document, then again for the second document, until the nth document. I have been trying some while loop stuff but I'm just not getting there. And if possible print each not a new file, but I think I figure out the last bit.

for T in LastWrite_Time['result'][:n]:
        print 'Time & Date =',T['value']

for D in DeltaTimeBetweenPoints['result'][:n]:
    print D['value']

for a in Data['result'][:n]:      #only print the first result in the list
    print a['value']
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

list1 = LastWrite_Time['result']
list2 = DeltaTimeBetweenPoints['result']
list3 = Data['result']

for T, D, A in zip(list1, list2, list3):
    print 'Time & Date =',T['value']
    print D['value']
    print a['value']

This will at first take the 1st element of each list and print values, then the 2nd element of each list and print them, and so on.

zip takes lists and iterates the elements from each list one by one, for all the lists.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda