title: How to change a list of strings to a list of integers
body: <p>I'm writing a program that takes a user file (a list of numbers, in this case) and calculate the mean, median, and mode of the list. However, I'm having a lot of trouble figuring out how to convert the number strings into integers. When I try, I get the error: "Invalid literal for int() in base 10" and then the first number of my list. No matter what I try I can't seem to convert the list even though this is the solution I keep seeing. Because of this, when I sort my list, it does not sort in numerical order. My mode function also seems to not be working very well, and even after a few days I can't figure out why. I would attach the file but there doesn't seem to be a way to do that, sorry. Hopefully this is enough information to see what might be causing the issues.</p>
  
  <pre><code>def CalculateMode(numbers):
      dictionary = dict()
      for num in numbers:
          if num in dictionary:
              dictionary[num] = dictionary[num] + 1
          else:
              dictionary[num] = 1
          maximum = max(dictionary.values())
          for key in dictionary:
              if dictionary[key] == maximum:
                  print("The mode is " + key + ".")
  
  def Main():
      openFile = open("testfile.txt", 'r')
      data = openFile.read()
      numbers = data.split()
      for num in numbers:
          num = int(num)
          return num
      numbers = sorted(numbers)
      print(numbers)
      while True:
          choice = input("Calculate Mode [1]  Exit [2]: ")
          if choice == "1":
              CalculateMode(numbers)
          elif choice == "2":
              break
          else:
              print("Please choose one of the above options.")
  
  Main()
  </code></pre>