I frequently write code like:
lines = open('wordprob.txt','r').readlines()
words = open('StdWord.txt','r').readlines()
i = 0
for line in lines:
v = [eval(s) for s in line.split()]
if v[0] > v[1]:
print words[i].strip(),
i += 1
Is it possible to avoid use variable i and make the program shorter?
Thanks.
You can try to use enumerate,
http://docs.python.org/tutorial/datastructures.html#looping-techniques