Python Forum
Using values from a list of tuples within a loop
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using values from a list of tuples within a loop
#5
Hello buran,

(Mar-09-2018, 08:17 AM)buran Wrote: can you be more specific what you mean by how to use or assign the second values of the tuples to each iteration of the output and # values that I want to have come out (in order) with the output of the gen_map function where currently str(i) is being used.?

Sure, I'm storing tuples in the srcids list. I'm using the first element of the tuples in that list to have the loop within the gen_map function continue to the next iteration. That's working fine. In addition to that, I want the second value of each tuple to be output as part of the string that's built up by concatenating what you see in the print function.

So right now the output looks like this:

2/9/1/0/1/2,10,0,0
2/9/1/0/1/3,11,0,0
2/9/1/0/1/4,12,0,0
2/9/1/0/1/5,13,0,0
2/9/1/0/1/6,14,0,0
2/9/1/0/1/7,15,0,0
2/9/1/0/2/0,16,0,0
2/9/1/0/2/1,17,0,0
2/9/1/0/2/2,18,0,0
2/9/1/0/2/3,19,0,0
2/9/1/0/2/4,20,0,0
2/9/1/0/2/5,21,0,0
2/9/1/0/2/6,22,0,0
2/9/1/0/2/7,23,0,0
2/9/1/0/3/0,24,0,0
2/9/1/0/3/1,25,0,0
2/9/1/0/6/1,49,0,0
2/9/1/0/6/2,50,0,0
2/9/1/0/6/3,51,0,0
2/9/1/0/6/4,52,0,0
2/9/1/0/6/5,53,0,0
2/9/1/0/6/6,54,0,0
2/9/1/0/6/7,55,0,0
2/9/1/0/7/0,56,0,0
2/9/1/0/7/1,57,0,0
2/9/1/0/7/2,58,0,0
2/9/1/0/7/3,59,0,0
And I want it to come out like this:

2/9/1/0/1/2,1115,0,0
2/9/1/0/1/3,1116,0,0
2/9/1/0/1/4,1117,0,0
2/9/1/0/1/5,1118,0,0
2/9/1/0/1/6,1119,0,0
2/9/1/0/1/7,1120,0,0
2/9/1/0/2/0,1121,0,0
2/9/1/0/2/1,1122,0,0
2/9/1/0/2/2,1123,0,0
2/9/1/0/2/3,1124,0,0
2/9/1/0/2/4,1125,0,0
2/9/1/0/2/5,1126,0,0
2/9/1/0/2/6,1127,0,0
2/9/1/0/2/7,1128,0,0
2/9/1/0/3/0,1129,0,0
2/9/1/0/3/1,1130,0,0
2/9/1/0/6/1,115,0,0
2/9/1/0/6/2,116,0,0
2/9/1/0/6/3,117,0,0
2/9/1/0/6/4,118,0,0
2/9/1/0/6/5,119,0,0
2/9/1/0/6/6,120,0,0
2/9/1/0/6/7,121,0,0
2/9/1/0/7/0,122,0,0
2/9/1/0/7/1,123,0,0
2/9/1/0/7/2,124,0,0
2/9/1/0/7/3,125,0,0
Thanks again for your help.

jtpy
Reply


Messages In This Thread
RE: Using values from a list of tuples within a loop - by jtpy - Mar-09-2018, 09:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 885 May-27-2024, 04:54 PM
Last Post: wardancer84
  Copying the order of another list with identical values gohanhango 7 1,309 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Search Excel File with a list of values huzzug 4 1,375 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Loop through values and compare edroche3rd 6 789 Oct-18-2023, 04:04 PM
Last Post: edroche3rd
  Comparing List values to get indexes Edward_ 7 1,368 Jun-09-2023, 04:57 PM
Last Post: deanhystad
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,355 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Adding values with reduce() function from the list of tuples kinimod 10 2,891 Jan-24-2023, 08:22 AM
Last Post: perfringo
  user input values into list of lists tauros73 3 1,178 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  Creating a loop with dynamic variables instead of hardcoded values FugaziRocks 3 1,587 Jul-27-2022, 08:50 PM
Last Post: rob101
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,299 Jun-05-2022, 05:24 AM
Last Post: onenessboy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020