For Loop Not iterating correctly With Functions Called
Question: I have been having some problems getting this for loop to iterate, call
functions, and then return to the loop and iterate again. It only runs twice
as of right now. I figure it has a way to do with how I am calling functions
inside of the loop. Is there something I am missing?

    
    
    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    import os, csv, xlrd, sys
    import pandas as pd
    import numpy as np
    from openpyxl import load_workbook
    
    def PosFinder():
    
        with open('FinalMutations.csv', 'w') as csvf:
            writer = csv.writer(csvf, delimiter=' ') 
            csvf.close()
    
        MutFinder()
    
    def MutFinder():
        df = pd.read_csv('mutation-table.csv', sep=None)
    
        MutationList = df['Seq ID']
    
        Positions = list(set(MutationList))
    
        n = len(Positions)
    
        for i in (0, n):
            print(i)
            MutationPos=Positions[i]
            MutationFound=df[df['Seq ID'].str.contains(MutationPos)]
            FreqCheck(MutationFound)
            i+=1
    
    
        print('Program Complete!')
    
    
    def FreqCheck(MutationFound):
    
        PFreqs=MutationFound.ix[:,3]
        PFreqs=PFreqs.str.strip('%')
        Freqs= PFreqs.astype(float)
    
        if len(MutationFound)==1:
            Check = all(i<10.0 for i in Freqs)
            if Check in [False, 'False']:
                ToExcel(MutationFound)
        else:
                Check = all(i<10.0 for i in Freqs)
    
                if Check in [False, 'False']:
                   ConstantFreq(MutationFound)
    
    
    def ConstantFreq(MutationFound):        
    
        PFreqs=MutationFound.ix[:,3]
        PFreqs=PFreqs.str.strip('%')
        Freqs= PFreqs.astype(float)
        Flag= all(x==Freqs[0] for x in Freqs)
    
        if Flag in [False, 'False']:
            RangeCheck(MutationFound, Freqs)
    
    def RangeCheck(MutationFound, Freqs):
    
        minFreq= Freqs.min()
        maxFreq= Freqs.max()
        netFreq= maxFreq-minFreq
    
        if netFreq>10:
            ToExcel(MutationFound)
    
    
    def ToExcel(MutationFound):
    
        with open('FinalMutations.csv', 'a') as csvf:
    
            writer = csv.writer(csvf, delimiter=' ') 
            for row in MutationFound:       
                    writer.writerow(row)
    
    
    ###Start Program### 
    PosFinder()
    


Answer: The for loop currently takes `(0, n)`, which is just list of the two values
`0` and `n`.

Change to `range(n)` to get all values `0`,`1`,...,`n-1`

