fork download
  1. from collections import OrderedDict
  2.  
  3. k = ['1', '16', '11', '20', '3', '26', '7', '22']
  4. v = ['2', '3', '2', '3', '5', '4', '1', '4']
  5.  
  6. d = OrderedDict(zip(k, v))
  7.  
  8. # will only print the keys since we have access to those only
  9. print('Keys only...')
  10. for i in d:
  11. print(i)
  12.  
  13.  
  14.  
  15. # to access both keys and values we have to call .items()
  16. print('\nKeys and values...')
  17. for k, v in d.items():
  18. print(k, v)
Success #stdin #stdout 0.03s 10240KB
stdin
Standard input is empty
stdout
Keys only...
1
16
11
20
3
26
7
22

Keys and values...
1 2
16 3
11 2
20 3
3 5
26 4
7 1
22 4