python


SUBMITTED BY: Guest

DATE: April 3, 2013, 12:01 p.m.

FORMAT: Text only

SIZE: 251 Bytes

HITS: 1096

  1. >>> zip([1,2,3], ['a','b','c'])
  2. [(1, 'a'), (2, 'b'), (3, 'c')]
  3. >>> a = ['a','b','c']
  4. >>> b = range(3)
  5. >>> b
  6. [0, 1, 2]
  7. >>> d = {key: value for (key, value) in zip(a,b) }
  8. >>> d
  9. {'a': 0, 'c': 2, 'b': 1}

comments powered by Disqus