title: Looping through a list of proxies
body: <p>I am currently working on a function that is to loop through a list of functions and then restart back at the top once it reaches the bottom. So far this is the code that I have:</p>
  
  <pre><code>import time
  
  createLimit = 100
  proxyFile = 'proxies.txt'
  
  
  def getProxies():
    proxyList = []
    with open(proxyFile, 'r') as f:
      for line in f:
        proxyList.append(line)
  
    return proxyList
  
  
  proxyList = getProxies()
  
  
  def loopProxySwitch():
    print("running")
    current_run = 0
    while current_run &lt;= createLimit:
      if current_run &gt;= len(proxyList):
        lengthOfList = len(proxyList)
        useProxy = proxyList[current_run%lengthOfList]
        print("Current Ip: "+useProxy)
        print("Current Run: "+current_run)
        print("Using modulus")
        return useProxy
      else:
        useProxy = proxyList[current_run]
        print("Current Ip: "+useProxy)
        print("Current Run: "+current_run)
        return useProxy
      time.sleep(2)
    print("Script ran")
  
  loopProxySwitch()
  </code></pre>
  
  <p>The problem that I am having is that the loopProxySwitch function does not return or print anything within the while loop, however I don't see how it would be false. Here is the format of the text file with fake proxies: </p>
  
  <pre><code>111.111.111.111:2222
  333.333.333.333:4444
  444.444.444.444:5555
  777.777.777.777:8888
  919.919.919.919:0000
  </code></pre>
  
  <p>Any advice on this situation? I intend to incorporate this into a program that I am working on, however instead of cycling through the file on a timed interval, it would only loop on a certain returned condition (such as a another function letting the loop function know that some function has ran and that it is time to switch to the next proxy). If this is a bit confusing, I will be happy to elaborate and clear any confusion. Any suggestions, ideas, or fixes are appreciated. Thanks!</p>
  
  <p><strong>EDIT:</strong> Thanks to the comments below, I fixed the printing issue. However, the function does not loop through all the proxies... Any suggestions?</p>