0
林基本上需要能夠在列表中顯示或隱藏的項目顯示或隱藏的項目在列表中的Python
這樣,當我選擇一個選項,如果它是隱藏的,如下面
所示的項目a = ['A','B','C','D','E','F','G','H','I']
def askChoice():
choice = 0
if choice == 1:
a[-1] = X ##Therefore last item in the list is hidden
elif choice == 2:
a[-1] = a[-1] ##Therefore item shown
else:
a[-1] = [] ## There an empty placeholder where any other item can be placed
return choice
呃,什麼?也許你可以詳細說明這個問題的背景,因爲你似乎試圖用一個毫無意義的列表來做一些事情。 'a [-1] = a [-1]'?那什麼都不做。 – Amber 2012-03-04 02:42:21
將'choice'設置爲0將確保每次都執行最後一個條件'else'。 – prelic 2012-03-04 02:45:25
@Amber,選擇2中的a [-1]應該顯示最後一個項目,如果它已被隱藏使用X.順便說一句,即時通訊不熟悉python,所以我需要你的幫助。謝謝 – Sammson 2012-03-04 02:47:22