Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda