title: Python loop to print salaries within range of the average
body: <p>I'm an absolute beginner to Python and am tasked with creating a program that does a few things:</p>
  
  <ol>
  <li>Inputs employee names into a list.</li>
  <li>Inputs that employee's salary after inputting their name.</li>
  <li>Totals the salaries in a list, (2 lists: names[] and salaries[]).</li>
  <li>Finds the average salary after totaling.</li>
  <li>Prints employees that earn within $5,000 of the average salary (Where I'm stuck).</li>
  </ol>
  
  <p>Please see my code below:</p>
  
  <pre><code># function to total the salaries entered into the "newSalary" variable and "salaries[]".
  def totalSalaries(salaries):
      total = 0
      for i in salaries:
          total += i
      return total
  
  # Finds the average salary after adding and dividing salaries in "salaries[]".
  def averageSalaries(salaries):
      l = len(salaries)
      t = totalSalaries(salaries)
      ave = t / l
      return ave
  
  # Start main
  def main():
      # Empty names list for "name" variable.
      names = []
  
      # Empty salaries list for "salary" and "newSalary" variables. 
      salaries = []
  
      # Starts the loop to input names and salaries.
      done = False
      while not done:
          name = input("Please enter the employee name or * to finish: ")
          salary = float(input("Please enter the salary in thousands for " + name + ": "))
  
          # Try/except to catch exceptions if a float isn't entered.
          # The float entered then gets converted to thousands if it is a float. 
          try:
              s = float(salary)
  
          # Message to user if a float isn't entered. 
          except:
              print("Please enter a valid float number.")
              done = False
          newSalary = salary * 1000
  
          # Break in the loop, use * to finish inputting Names and Salaries.
          if name == "*":
              done = True
  
          # Appends the names into name[] and salaries into salaries[] if * isn't entered.
          # Restarts loop afterwards if * is not entered. 
          else:
              names.append(name)
              salaries.append(newSalary)
      # STUCK HERE. Need to output Names + their salaries if it's $5,000 +- the total average salary.
      for i in range(len(salaries)):
          if newSalary is 5000 &gt; ave &lt; 5000:
              print(name + ", " + str(newSalary))
  
      # Quick prints just to check my numbers after finishing with *. 
      print(totalSalaries(salaries))
      print(averageSalaries(salaries))
  
  
  main()
  </code></pre>
  
  <p>Any info is greatly appreciated. I hope the rest of the functions and logic in this program makes sense. </p>