尝试制作一个程序,提示用户输入一个着名的人名并继续询问,直到他们输入“完成”并打印出名称和名称数量的列表。谁能给我一点帮助?
def main():
cList = []
cName = []
while cName != ("done"):
cList.append(cName)
cName = input("Enter another name: ")
print("# of names entered: "), [cList]
i = 0
while i < len(cList):
print myList[i]
i += 1
return
main()
答案 0 :(得分:0)
喜欢这个吗?
names = []
while True:
names.append(raw_input('Enter name: '))
if names[-1] == 'done':
names.pop()
break
print("# of names %i" % len(names))
for name in names:
print(name)