BSHuniversity BSHuniversity - 1 year ago 78
Python Question

While loop incrementer not functioning properly

Right now, my code is correctly spitting out the first game (identified by start_id) in games. I am trying to increment in the bottom two lines, but the while loop doesn't seem to read the fact that I'm incrementing. So the input of this with start_id 800 and end_id 802 is just the information from 800, for some reason.

Am I using the incrementers correctly? Should I be initializing one of i or start_id elsewhere?

games = console(start_id, end_id)
final_output = []

while start_id < (end_id + 1):
single_game = []
i = 0
game_id = games[i][0]
time_entries = games[i][1][2][0]
play_entries = games[i][1][2][1]
score_entries = games[i][1][2][2]
team_entries = games[i][1][2][3]
bovada = games[i][1][0][0][0]
at_capacity = games[i][1][0][1]
idisagree_yetrespect_thatcall = games[i][1][0][2][0]
imsailingaway = games[i][1][1][0][0]
homeiswheretheheartis = games[i][1][1][1][0]

zipper = zip(time_entries, play_entries, score_entries, team_entries)

for play_by_play in zipper:

start_id += 1
i += 1
return final_output

Answer Source

Your problem is that you initialize the increment-er i inside the while loop so every time your loop iterates i is reset to zero.

Try changing it to:

i = 0
while start_id < (end_id + 1):
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download