title: Trying to rewrite variables
body: <pre><code>    print("Please enter some integers to average. Enter 0 to indicate you are done.")
  
  #part (a) -- what are the initial values for these variables?
  #incomplete
  done = 0
  mySum = 0
  count =  0   
  while not done:
      valid = False #don't yet have a valid input
      while not valid: #this loop keeps attempting to get input until the user enters an integer
          try:
              num = int(input())
              valid = True #now the input is valid, and can use it
          except ValueError:
              print("Input must be an integer.")  
      if num == 0:
          break
          mySum = sum(num)
          count = len(num)
          #part (b) -- fill in the inside of this if statement
          #incomplete
  
  
      else: print num  #part (c) -- if num is not zero, then... fill in the code
          #incomplete
  
  
  avg = mySum / count #calculates average
  print("The average is", avg) #prints average
  </code></pre>
  
  <p>Excuse the comments as this is an assignment from an instructor. As you can see, line 28 of the code shows a divide by zero error for variable mySum. In the while loop I overwrote(or at least tried to) mySum, but still got the division error. Am I going about this correctly or is there some syntax I'm not following? </p>
  
  <p>EDIT: New attempt:</p>
  
  <pre><code>#part (a) -- what are the initial values for these variables?
  #incomplete
  done = 0
  mySum = [] 
  count =  len(mySum)  
  
  while not done:
      valid = False #don't yet have a valid input
      while not valid: #this loop keeps attempting to get input until the user enters an integer
          try:
              num = int(input())
              valid = True #now the input is valid, and can use it
          except ValueError:
              print("Input must be an integer.")  
      if num == 0:
          break
          #part (b) -- fill in the inside of this if statement
          #incomplete
  
  
      else: mySum.append(num)
      count +=1#part (c) -- if num is not zero, then... fill in the code
          #incomplete
  
  
  avg = sum(mySum) / count #calculates average
  
  if len(mySum) == 0:
      print "You haven't entered any number"
  else: print ("The average is", avg) 
  </code></pre>