2 回答
TA贡献1871条经验 获得超8个赞
您必须让 show() 在其中包含一个参数。例如:
def show(n):
print(n)
因此,当您调用 show(n) 时,它会将您包含的任何内容打印为 n。
所以如果你打电话给 show(name)。它会打印出名称。
def show(n):
print(n)
show(name) #This would print out name.
除非您返回一个值,否则您也不需要return。Return 不会使代码返回,它只会使函数返回一个值。所以你确实需要返回 list() 和 create(),但不需要返回 show(n)。
编辑 您还希望在调用 create 时将用户输入设置为变量。
def main():
print("Choose from the following list:")
while True:
choice = lista()
if (choice == 0):
print("Thanks for using the program!")
break
elif (choice == 1):
name = create() #Here is where you should change it
elif (choice == 2):
show(name)
else:
print("Input not detected.\nStopping.")
break
添加回答
举报
