数组仅列出第一项,我完全不知道我做错了什么,所以我给出了代码的每一部分。该程序应该列出一个列表,并询问您是否要再创建一个列表,依此类推,直到完成10次(此操作有效)的部分是在我使用此部分时:
for a in list1:
print ("• {}".format(a))
每次尝试列出它时,它只会列出第一项。 PS:我只是编程新手,所以请不要太苛刻。谢谢。
import time
def function1():
function =input("Please enter a function. ")
function_options='view','edit','newlist'
while function not in function_options:
function =input("Please enter a function, if you do not know what a function is then please read the tutorial. ")
if function in function_options:
break
else:
function =input("Please enter a function, if you do not know what a function is then please read the tutorial. ")
function1()
if function == 'newlist':
print ("no")
elif function == 'view':
listselect = input("Which list would you like to view? ")
if listselect == var1:
for a in list1:
print ("• {}".format(a))
function1()
elif listselect == var2:
for b in list2:
print ("• {}".format(b))
function1()
elif listselect == var3:
for c in list3:
print ("• {}".format(c))
function1()
elif listselect == var4:
for d in list4:
print ("• {}".format(d))
function1()
elif listselect == var5:
for e in list5:
print ("• {}".format(e))
function1()
elif listselect == var6:
for f in list6:
print ("• {}".format(f))
function1()
elif listselect == var7:
for g in list7:
print ("• {}".format(g))
function1()
elif listselect == var8:
for h in list8:
print ("• {}".format(h))
function1()
elif listselect == var9:
for i in list9:
print ("• {}".format(i))
function1()
elif listselect == var10:
for j in list10:
print ("• {}".format(j))
function1()
elif function == 'edit':
editoption = input("Add or remove items? a/r ")
if editoption == 'a':
listselect = input("Which list would you like to add to? ")
if listselect == var1:
for a in list1:
print ("• {}".format(a))
print ("What would you like to call your new item?")
additem1 = str(input())
list1.append(additem1)
for a in list1:
print ("• {}".format(a))
time.sleep(2)
function1()
elif listselect == var2:
for b in list2:
print ("• {}".format(b))
print ("What would you like to call your new item?")
additem2 = str(input())
list2.append(additem2)
for b in list2:
print ("• {}".format(b))
time.sleep(2)
function1()
elif listselect == var3:
for c in list3:
print ("• {}".format(c))
print ("What would you like to call your new item?")
additem3 = str(input())
list3.append(additem3)
for c in list3:
print ("• {}".format(c))
time.sleep(2)
function1()
elif listselect == var4:
for d in list4:
print ("• {}".format(d))
print ("What would you like to call your new item?")
additem4 = str(input())
list4.append(additem4)
for d in list4:
print ("• {}".format(d))
time.sleep(2)
function1()
elif listselect == var5:
for e in list5:
print ("• {}".format(e))
print ("What would you like to call your new item?")
additem5 = str(input())
list5.append(additem5)
for e in list5:
print ("• {}".format(e))
time.sleep(2)
function1()
elif listselect == var6:
for f in list6:
print ("• {}".format(f))
print ("What would you like to call your new item?")
additem6 = str(input())
list6.append(additem6)
for f in list6:
print ("• {}".format(f))
time.sleep(2)
function1()
elif listselect == var7:
for g in list7:
print ("• {}".format(g))
print ("What would you like to call your new item?")
additem7 = str(input())
list7.append(additem7)
for g in list7:
print ("• {}".format(g))
time.sleep(2)
function1()
elif listselect == var8:
for h in list7:
print ("• {}".format(h))
print ("What would you like to call your new item?")
additem7 = str(input())
list7.append(additem7)
for h in list7:
print ("• {}".format(h))
time.sleep(2)
function1()
elif listselect == var9:
for i in list7:
print ("• {}".format(i))
print ("What would you like to call your new item?")
additem7 = str(input())
list7.append(additem7)
for i in list7:
print ("• {}".format(i))
time.sleep(2)
function1()
elif listselect == var10:
for j in list7:
print ("• {}".format(j))
print ("What would you like to call your new item?")
additem7 = str(input())
list7.append(additem7)
for j in list7:
print ("• {}".format(j))
time.sleep(2)
function1()
elif editoption == 'r':
listselect = input("Which list would you like to remove items from? ")
if listselect == var1:
for a in list1:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem1 = int(input())
removeitem1 = removeitem1+1
list1.remove(list1[removeitem1])
time.sleep(2)
function1()
elif listselect == var2:
for a in list2:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem2 = int(input())
removeitem2 = removeitem2+1
list2.remove(list1[removeitem2])
time.sleep(2)
function1()
elif listselect == var3:
for a in list3:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem3 = int(input())
removeitem3 = removeitem3+1
list3.remove(list3[removeitem3])
time.sleep(2)
function1()
elif listselect == var4:
for a in list4:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem4 = int(input())
removeitem4 = removeitem4+1
list4.remove(list4[removeitem4])
time.sleep(2)
function1()
elif listselect == var5:
for a in list5:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem5 = int(input())
removeitem5 = removeitem5+1
list5.remove(list5[removeitem5])
time.sleep(2)
function1()
elif listselect == var6:
for a in list6:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem6 = int(input())
removeitem6 = removeitem6+1
list6.remove(list6[removeitem6])
time.sleep(2)
function1()
elif listselect == var7:
for a in list7:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem7 = int(input())
removeitem7 = removeitem7+1
list7.remove(list7[removeitem7])
time.sleep(2)
function1()
elif listselect == var8:
for a in list8:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem8 = int(input())
removeitem8 = removeitem8+1
list8.remove(list8[removeitem1])
time.sleep(2)
function1()
elif listselect == var9:
for a in list9:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem9 = int(input())
removeitem9 = removeitem9+1
list9.remove(list9[removeitem9])
time.sleep(2)
function1()
elif listselect == var10:
for a in list10:
print ("• {}".format(a))
print ("Which item would you like to remove?")
removeitem10 = int(input())
removeitem10 = removeitem10+1
list10.remove(list10[removeitem10])
time.sleep(2)
function1()
listamount = int(("0"))
print ("Would you like a tutorial? y/n")
tutorial = input()
if tutorial == 'y':
print ("INSERT_TUTORIAL_HERE")
time.sleep(0.25)
elif tutorial == 'n':
print ("Well aren't you clever?")
time.sleep(0.25)
else:
print ("Please enter y/n ")
time.sleep(1)
exec(open("main.py").read())
print ("What would you like your list to be called?")
var1 = input()
keepgoing1 = True
list1 = []
while keepgoing1:
print ("Add item to list: {}. ".format(var1))
newitem1 = input()
if newitem1 == "stop":
keepgoing1 = False
listamount = listamount+1
elif newitem1 == "done":
keepgoing1 = False
listamount = listamount+1
else:
list1.append(newitem1)
print (list1)
createlist2 = input("Create another list? y/n ")
if createlist2 == 'n':
function1()
elif createlist2 == 'y':
print ("What would you like your second list to be called?")
var2 = input()
keepgoing2 = True
list2 = []
while keepgoing2:
print ("Add item to list: {}. ".format(var2))
newitem2 = input()
if newitem2 == "stop":
keepgoing2 = False
listamount = listamount+1
elif newitem2 == "done":
keepgoing2 = False
listamount = listamount+1
else:
list2.append(newitem2)
print (list2)
createlist3 = input("Create another list? y/n ")
if createlist3 == 'n':
function1()
elif createlist3 == 'y':
print ("What would you like your third list to be called?")
keepgoing3 = True
list3 = []
while keepgoing3:
print ("Add item to list: {}. ".format(var3))
newitem3 = input()
if newitem3 == "stop":
keepgoing3 = False
listamount = listamount+1
elif newitem3 == "done":
keepgoing3 = False
listamount = listamount+1
else:
list3.append(newitem3)
print (list3)
createlist4 = input("Create another list? y/n ")
if createlist4 == 'n':
function1()
elif createlist4 == 'y':
print ("What would you like your fourth list to be called?")
keepgoing4 = True
list4 = []
while keepgoing4:
newitem4 = input()
if newitem4 == "stop":
keepgoing4 = False
listamount = listamount+1
elif newitem4 == "done":
keepgoing4 = False
listamount = listamount+1
else:
list4.append(newitem4)
print (list4)
createlist5 = input("Create another list? y/n ")
if createlist5 == 'n':
function1()
elif createlist5 == 'y':
print ("What would you like your fifth list to be called?")
keepgoing5 = True
list5 = []
while keepgoing5:
newitem5 = input()
if newitem5 == 'stop':
keepgoing5 = False
listamount = listamount+1
elif newitem5 == 'done':
keepgoing5 = False
listamount = listamount+1
else:
list5.append(newitem5)
print (list5)
createlist6 = input("Create another list? y/n ")
if createlist6 == 'n':
function1()
elif createlist6 == 'y':
print ("What would you like your sixth list to be called?")
keepgoing6 = True
list6 = []
while keepgoing6:
newitem6 = input()
if newitem6 == 'stop':
keepgoing6 = False
listamount = listamount+1
elif newitem6 == 'done':
keepgoing6 = False
listamount = listamount+1
else:
list6.append(newitem6)
print (list6)
createlist7 = input("Create another list? y/n ")
if createlist7 == 'n':
function1()
elif createlist7 == 'y':
print ("What would you like your seventh list to be called?")
keepgoing7 = True
list7 = []
while keepgoing7:
newitem7 = input()
if newitem7 == 'stop':
keepgoing7 = False
listamount = listamount+1
elif newitem7 == 'done':
keepgoing7 = False
listamount = listamount+1
else:
list7.append(newitem7)
print (list7)
createlist8 = input("Create another list? y/n ")
if createlist == 'n':
function1()
elif createlist8 == 'y':
print ("What would you like your eighth list to be called?")
keepgoing8 = True
list8 = []
while keepgoing8:
newitem8 = input()
if newitem8 == 'stop':
keepgoing8 = False
listamount = listamount+1
elif newitem8 == 'done':
keepgoing8 = False
listamount = listamount+1
else:
list8.append(newitem8)
print (list8)
createlist9 = input("Create another list? y/n ")
if createlist9 == 'n':
function1()
elif createlist9 == 'y':
print ("What would you like your ninth list to be called?")
keepgoing9 = True
list9 = []
while keepgoing9:
newitem9 = input()
if newitem9 == 'stop':
keepgoing9 = False
listamount = listamount+1
elif newitem == 'done':
keepgoing9 = False
listamount = listamount+1
else:
list9.append(newitem9)
print (list9)
createlist10 = input("Create another list? y/n")
if createlist10 == 'n':
function1()
elif createlist10 == 'y':
print ("What would you like your tenth list to be called?")
keepgoing10 = True
list10 = []
while keepgoing10:
newitem10 = input()
if newitem10 == 'stop':
keepgoing10 = False
listamount = listamount+1
if newitem10 == 'done':
keepgoing10 = False
listamount = listamount+1
else:
list10.append(newitem10)
print (list10)
print ("I think ten lists is enough...")
print ("commercial use detected, please buy a licence.")