Advertisement
rdrewd-facebook

dictionary comprehension test

Aug 3rd, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. >>> listdict2dict={{names[k]:v for k,v in d.items()}}
  2. Traceback (most recent call last):
  3. File "<stdin>", line 1, in <module>
  4. TypeError: unhashable type: 'dict'
  5. >>>
  6. >>> listdict2dict={name[k]:v for k,v in d.items()}
  7. Traceback (most recent call last):
  8. File "<stdin>", line 1, in <module>
  9. File "<stdin>", line 1, in <dictcomp>
  10. NameError: global name 'name' is not defined
  11. >>> listdict2dict={names[k]:v for k,v in d.items()}
  12. >>> print listdist2dict
  13. Traceback (most recent call last):
  14. File "<stdin>", line 1, in <module>
  15. NameError: name 'listdist2dict' is not defined
  16. >>> print listdict2dict
  17. {'Larry': 1000.0, 'Moe': 990, 'Curly': 1200.5}
  18. >>> listdict2dict={names[k]:v for (k,v) in d.items()}
  19. >>> print listdict2dict
  20. {'Larry': 1000.0, 'Moe': 990, 'Curly': 1200.5}
  21. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement