我想要一个小程序来计算用户输入的每个零件号。 这就是我能做的
是否有办法将零件号及其频率导出到.csv文件
from collections import Counter
thislist = []
frequency = []
partnumber = ""
def mainmanu():
print ("1. Create List")
print ("2. Print list")
print ("3. Exit")
while True:
try:
selection = int (input("Enter Choice: ")
if selection ==1:
creatlist(thislist)
elif selection ==2:
counteach(thislist)
elif selection ==3:
break
except ValueError:
print ("invalid Choice. Enter 1-3")
def creatlist(thislist)
# while True:
partnumber = input ("Enter Part number: ")
if partnumber =="end":
print(thislist)
mainmanu()
break
thislist.append(partnumber)
def counteach(thislist)
Counter(thislist)
mainmanu()
mainmanu()
欢迎来到StackOverflow
您正在调用另一个函数中的mainmanu函数,该函数由mainmanu函数调用。相反,您应该做的是让mainmanu调用所有其他助手函数。另外,您不能在另一个函数中调用break,而期望在哪里调用它
执行过程如下:
调用mainmanu,它调用createlist,在它完成执行后,它继续执行它离开的指令
相关问题 更多 >
编程相关推荐