Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- names = ['A', 'B', 'C']
- score = {}
- values = [0,0,0]
- #Creat a dictory:{'A': [0, 0, 0], 'B': [0, 0, 0], 'C': [0, 0, 0]}
- for name in names:
- score.setdefault(name, values)
- print(score)
- #Change the value of key B
- for name in names:
- score['B'][0] = 1
- print(score)
- # The result is:{'A': [1, 0, 0], 'B': [1, 0, 0], 'C': [1, 0, 0]}
Add Comment
Please, Sign In to add comment