Guest User

Untitled

a guest
Jun 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. names = ['A', 'B', 'C']
  2. score = {}
  3. values = [0,0,0]
  4.  
  5. #Creat a dictory:{'A': [0, 0, 0], 'B': [0, 0, 0], 'C': [0, 0, 0]}
  6. for name in names:
  7. score.setdefault(name, values)
  8. print(score)
  9.  
  10. #Change the value of key B
  11. for name in names:
  12. score['B'][0] = 1
  13. print(score)
  14.  
  15. # The result is:{'A': [1, 0, 0], 'B': [1, 0, 0], 'C': [1, 0, 0]}
Add Comment
Please, Sign In to add comment