Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # dict_from_list_comprehension.py
- t = [(10, 20), (30, 40), (50, 60)]
- print dict(t) # {10: 20, 30: 40, 50: 60}
- gen = [(i, i+1) for i in range(1, 6, 2)]
- print dict(gen) # {1: 2, 3: 4, 5: 6}
- print {i: i*100 for i in range(1, 4)} # {1: 100, 2: 200, 3: 300}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement