title: How to allow input only string value of "stop", "", then check and convert to float
body: <p>Hi I am having trouble with the end of my loop.  I need to accept the input as a string to get the "stop" or the "" but I don't need any other string inputs.  Inputs are converted to float and then added to a list but if the user types "bob" I get the conversion error, and I cant set the input(float) because then I can't accept "stop".</p>
  
  <p>Full current code is below.</p>
  
  <p>My current thinking is as follows:</p>
  
  <ol>
  <li>check for "stop, ""</li>
  <li>check if the input is a float.</li>
  <li>if its not 1 or 2, then ask for a valid input.</li>
  </ol>
  
  <p>Any ideas please? If its something simple just point me in the direction and i'll try churn it out. Otherwise...</p>
  
  <p>Thanks</p>
  
  <pre><code># Write a progam that accepts an unlimited number of input as integers or floating point.
  # The input ends either with a blank line or the word "stop".
  
  
  mylist = []
  
  g = 0
  total = 0
  avg = 0
  
  
  def calc():
      total = sum(mylist);
      avg = total / len(mylist);
      print("\n");
      print ("Original list input: " + str(mylist))
      print ("Ascending list: " + str(sorted(mylist)))
      print ("Number of items in list: " + str(len(mylist)))
      print ("Total: " + str(total))
      print ("Average: " + str(avg))
  
  
  while g != "stop":
      g = input()
      g = g.strip()  # Strip extra spaces from input.
      g = g.lower()  # Change input to lowercase to handle string exceptions.
      if g == ("stop") or g == (""):
          print ("You typed stop or pressed enter") # note for testing
          calc() # call calculations function here
          break
  
  # isolate any other inputs below here ????? ---------------------------------------------
          while g != float(input()):
              print ("not a valid input")
      mylist.append(float(g))
  </code></pre>