title: Finding the mode of a list without built-in functions
body: <p>For my programming course, I need to find the mode of a list given by the user. We went through this starting code in class. Now we need to find the single or multiple modes given by the user. Also, when putting in this code, I get an error saying the index is out of range. Please help and thank you in advance!</p>
  
  <pre><code>def calculateMode(dataList):
      dataList.sort()
      position = 0
      largestCount = 0
      listLength = len(dataList)
      while(position &lt;= listLength):
          count = dataList.count(dataList[position])
          if(count &gt; largestCount):
              largestCount = count
              valuePosition = dataList[position]
          position += count
      return dataList[valuePosition]
  
  userList = []
  listEntry = float(input("Enter a number (Enter -1 to end):  "))
  while(listEntry &gt;= 0):
      userList.append(listEntry)
      listEntry = float(input("Enter a number (Enter -1 to end):  "))
  print(calculateMode(userList))
  </code></pre>