-1
該計劃不斷爲字符串值詢問,如果它們相等或不直到用戶,通過提示後詢問評估:經過多次迭代,程序跳轉到內環(蟒蛇)if語句
你想繼續計算? (是或否)
停止說「是」
既然有已經是第一個元素,這裏的while循環:
while inputswitch=="yes":
a=input("Enter name: ")
alist.append(a)
for i in range (0, len(alist)-1, 1):
if a.lower()==alist[i].lower():
alist.pop(len(alist)-1)
print("Match found")
inputswitch=input("Do you want to continue computations? (Yes or No) ").lower()
if (i==len(alist)-2) and (a.lower()!=alist[i].lower()):
print("Not equal")
inputswitch=input("Do you want to continue computations? (Yes or No) ").lower()
的問題不必在列表中5個元素之後開始(名爲ALIST),輸入與用索引< = 2元件第六元件。該程序同時運行,如果循環下作了發言。
爲了演示,具有像這樣的列表後:
['A', 'B', 'C', 'D', 'E']
I輸入完全相同Ç等第三元素。第一個if語句不運行,它打印:
"Match found"
但提示
你要繼續計算後? (是或否)
無論該提示的答案如何,它都會跳轉到第二條if語句;它不要求一個新的輸入和它打印:
"Not equal"
並再次詢問這個
是否要繼續計算? (是或否)
我迷路了。似乎是在for循環中的一個問題。