-2
上的Python 3.4.3工作
比方說,我已經創建了三個功效:
返回主功能蟒蛇
def choosing(mylist=[]):
print("We will have to make a list of choices")
appending(mylist)
done = False
while(done == "False"):
confirm = input("Is your list complete?[Y/N]")
if(confirm == "Y"):
print("Yaay! Choices creation complete."
"{} choices have been added successfully".format(len(mylist)))
done = True
elif(confirm == "N"):
action = input("What do you want to do? [Append/Delete]")
if(action == "Append"):
appending(mylist)
done = False
elif(action == "Delete"):
removing(mylist)
done = False
def appending(mylist1 = []):
print("Please type EOF when you want to stop!")
while True:
c = input("Please enter EOF to stop adding. Please enter a choice: ")
if(c=="EOF"):
break
else:
mylist1.append(c)
print("You have inserted {} choices".format(len(mylist1)))
print("Please verify them below: ")
for x in range(0, len(mylist1)):
print(mylist1[x])
def removing(mylist2 = []):
print("Following are choices: ")
r = input("What do you want to remove? ")
mylist2.remove(r)
print("{} successfully removed!".format(r))
現在的問題是,我不能只是調用choices()
在追加或刪除功能的選擇()函數將無限次地調用append。 那麼在追加或刪除列表中的數據後,如何恢復選擇?
把無所不在的'選擇'放到無限'while'循環中。 –
你能解釋何時以及如何調用append()或remove()'嗎? – ASCIIThenANSI
'def choices():'
'append(x)'ofcourse我有整個正確的代碼格式。 @ASCIIThenANSI –