第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 Python 中更改 For 循環(huán)的索引(在 if 語句之外)

在 Python 中更改 For 循環(huán)的索引(在 if 語句之外)

HUWWW 2022-07-05 18:48:35
我正在嘗試更改 for 循環(huán)的索引,具體取決于用戶是否要轉(zhuǎn)到上一個(gè)圖像(索引 = 索引 - 1)以及是否要轉(zhuǎn)到下一個(gè)圖像(索引 = 索引 + 1)但是,索引沒有改變外循環(huán)(在 if 語句之外)。flag = Falsewhile flag == False:    for i in range(len(all_image)):        image = all_image[i]        print(i)        userchoice = easygui.buttonbox(msg, image = image, choices=choices)        if userchoice == 'Next':            i = i+1        elif userchoice == 'Previous':            i = i-1        elif userchoice == 'cancel':            print('test')            flag = True            break       提前致謝。
查看完整描述

1 回答

?
慕斯709654

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊

不知道為什么存在 for 循環(huán),我很想將它的結(jié)構(gòu)更像這樣:


flag = False

idx = 0 #idx is where we are in the image list, and it gets modified by use choices in the while loop.

while flag == False:

    image = all_image[idx]

    print(idx)

    userchoice = easygui.buttonbox(msg, image = image, choices=choices)


    if userchoice == 'Next':

        idx += 1

    elif userchoice == 'Previous':

        idx -= 1

    elif userchoice == 'cancel':

        print('test')

        flag = True

        break     


查看完整回答
反對(duì) 回復(fù) 2022-07-05
  • 1 回答
  • 0 關(guān)注
  • 211 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)