簡體   English   中英

While循環增量器無法正常運行

[英]While loop incrementer not functioning properly

現在,我的代碼正確地吐出了游戲中的第一個游戲(由start_id標識)。 我試圖在最下面兩行進行遞增,但是while循環似乎並未讀取我正在遞增的事實。 因此,出於某種原因,使用start_id 800和end_id 802進行的輸入只是來自800的信息。

我是否正確使用增量器? 我應該在其他地方初始化i或start_id之一嗎?

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:
        single_game.append(game_id)
        single_game.append(play_by_play)
        single_game.append(bovada)
        single_game.append(at_capacity)
        single_game.append(idisagree_yetrespect_thatcall)
        single_game.append(imsailingaway)
        single_game.append(homeiswheretheheartis)

    start_id += 1
    i += 1
    final_output.append(single_game)
return final_output

您的問題是,您在while循環中初始化了遞增運算符i while因此每次循環迭代i都會重置為零。

嘗試將其更改為:

i = 0
while start_id < (end_id + 1):
    ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM