Blake Young
Blake Young

Reputation: 459

Merge three lists together so that each nth item corresponds to the other lists' nth item

I have three lists. I need to make a master list so that.

l_site = [www.example.com, www.example.com] 
l_overall = [3.5, 4.5]
l_workload= [4.5, 6.5]
master_list= {[www.example.com, 3.5, 4.5], [www.example.com, 4.5, 6.5]

All lists are of the same length. I need this master_list so that I can reference it later.

def make_master_list(site, overall, workload):
# connect three values with eachother in a list

master_list= {[www.example.com, 3.5, 4.5], [www.example.com, 4.5, 6.5]

Upvotes: 1

Views: 24

Answers (1)

match
match

Reputation: 11070

The magic you want is zip:

l_site = ['www.example.com', 'www.example.com'] 
l_overall = [3.5, 4.5]
l_workload= [4.5, 6.5]

list(zip(l_site, l_overall, l_workload))

Upvotes: 1

Related Questions