title: How to add a value to a key in dictionary in Python
body: <p>My question is that I want to make a program that displays names and scores. I want to get user input for a number and a name. If the name is in the dictionary, then it will append the value to the key but if it isn't, it will make a new key value pair. I have tried for hours but can't seem to do it.</p>
  
  <pre><code>class_1 = {'Farid':9, 'Manraj':5, 'Andy':7, 'Sajid':3}
  
  score=int(input("Enter a number"))
  name=input("What is your name?")
  
  if name in class_1.key():
      class_1[name]=score
  else:
      class_1[name]=score
  </code></pre>