Here's my for loop that does stuff:
for x in range(0, 100):
currentRate10 = srall10[x].current_rate
startRate10 = srall10[x].start_rate
lessons10 = srall10[x].sr_completed
if currentRate10 is not None and startRate10 is not None:
gain10 = currentRate10 - startRate10
else:
gain10 = 0
rateavg = gain10 / lessons10
rateavg returns 1.42. Seems accurate to me. However, when I put a variable in place of the 100 OR anything above 100, I get 0 returned back. So if I change 100 to 101, rateavg returns 0. If I put in a variable that contains 143, I still get 0.
srall10 contains a list
srall10 = DBSession.query(Summary).filter(Summary.sid == 6933).filter(
Summary.sr_completed.between(1, 10)).all()
There are 143 entries, this was found by the exact same query except with count() at the end instead of all()
Any ideas?
srall10directly instead of usingrange()then?for sr in srall:. But it's your actual values that might cause the problem. Is this Python 2 or Python 3?TypeError('list indices must be integers, not Summary',)This is python 2