0

I need to have the following dictionary actions = {'1': c1, '2': c2, '3': c3}

def c1():
    print 'c1'
def c2():
    print 'c2'
def c3():
    print 'c3'

commands1 = ['1', '2', '3']
commands2 = [c1, c2, c3]
actions = {}

What I tried:

for c1 in commands1:
    for c2 in commands2:
        actions = dict(zip(c1, c2))

But it gives an error argument #2 must support iteration

1 Answers1

0

This question is already answered here: Map two lists into a dictionary in Python

dict(zip(list_a, list _b))
Community
  • 1
  • 1
YpsilonZett
  • 100
  • 1
  • 7