title: Python dictionary average value function
body: <p>Why the program does not want to calculate the average value from the dictionary?</p>
  <pre><code>grades = {}
  
  def addGrade(grades):
      course = input(&quot;input course: &quot;)
      grade = int(input(&quot;input grade: &quot;))
      grades[course] = grade
  
  def printGrades(grades):
      print(&quot;all grades:&quot;)
      for c, grade in grades.items():
          print(c + &quot;\t&quot; + str(grade))
  
  def count(grades):
      n = len(grades.keys())
      print(n)
  
  def printAverage(grades):
      print(&quot;average grade:&quot; + sum(grades)/int(count))
  </code></pre>