candidates = ['abacus', 'ball', 'car']
for candidate in candidates:
if dict[candidate] == "true":
"""next"""
else:
continue
"""do something"""
我在這裏要做的是檢查字典中是否存在術語,如果存在,請將控制流移到列表中的下一項候選人。我在使用next()
時遇到問題。我如何去做這件事?如果條件符合,則列表中的下一項
「next」是什麼意思?如果它存在,你想要發生什麼?去下一個候選人是「繼續」會做的。 –
'continue'已經移動到迭代中的下一個元素,不是嗎?你想在if和else子句之間做什麼不同? –
你在尋找'continue'嗎? –