c1 = ['Russia', 'US', 'Germany']
c2 = ['007', '001', '049']

 

a = dict(Russia = '007', US = '001', Germany = '049' )
a
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

b = {'Russia' : '007', 'US': '001', 'Germany': '049'}
b
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

c = dict(zip(c1,c2))
c
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

d = dict([('Russia', '007'), ('US', '001'), ('Germany', '049')])
d
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

e = {c1:c2 for c1,c2 in zip(c1,c2)}
e
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

f = dict([(c1,c2) for c1,c2 in zip(c1,c2)])
f
{'Germany': '049', 'Russia': '007', 'US': '001'}

 

a == b == c == d == e == f
True
Write a comment:

*

Your email address will not be published.

© 2014 In R we trust.
Top
Follow us: