python loops without index
<p>I'm learning python and I love that you can loop through iterable objects without constantly creating index variables. </p>

<p>But I keep finding myself creating index variables anyway so I can reference them in calls from parallel objects. Like when I'm comparing two lists, or a list and a dictionary. </p>

<p>As requested: some examples </p>

<pre><code>`s= "GAGCCTACTAACGGGAT"# the strings we are evaluating
t= "CATCGTAATGACGGCCT"

c = 0# c = position of interest within the strings
m = 0 # m = number of mutations found so far. 

for i in s: # cycling through all nucleotides listed in s
if(i == t[c]): #compare s[c] to t[c]
    c +=1 # if equal, increase position counter
else:
    c+=1 # if not equal, increase both position and                 
    m+=1        #mutation counters.`
</code></pre>

<p>AND </p>

<pre><code>def allPossibleSubStr(s): #takes a dict of strings, finds the shortest, and produces a list of all possible substrings, thus a list of possible common substrings to all elements of the original dict
ks = s.keys()
c=0 #counter
j=0 # ks place holder for shortest string
subSTR = []

for i in ks: #finds the shortest entry in stringDict
    if(s[i] &lt; s[ks[(c+1)%len(s)]]):
        j=c
    c +=1

c=s[ks[j]] #c is now a string, the shortest... 
j=ks[j] # j is now a key string, the shortest...
n = (len(c)*(len(c)+1))/2 # number of subsets of c

#producing a list of possible substrings
for i in range(len(c)):
    for k in range(len(c)-i):
        subSTR.append(c[i:i+k+1])
        #print("i =" +str(i)+ " and k=" + str(k))
#is there a list function with eleminates duplicate entries. 
subSTR=list(set(subSTR))# a set does not have any duplicate entires
subSTR.sort(key=len) # sorts substring from shortest to longest string
subSTR.reverse()

return subSTR
</code></pre>

<p>Is there a way around this? </p>