def name_number():
name=input("Give the name for the new contact: ")
number=input("Give the number for the new contact: ")
return name
def directory():
search=input("Input the name you want to search in the directory: ")
print ("Number for Harry Callahan is", search)
ans=True
while ans:
print("Phone book ver. 1.0.1")
print("1) Add new number to the directory")
print("2) Search for a contact")
print("0) Quit")
ans=input("What would you like to do?: ")
break
if ans=="1":
x = str(name_number())
elif ans=="2":
directory(x)
elif ans=="0":
break
我正在编写此代码。但我只是得到了这么多的输出,之后没有任何工作]
电话簿版本。 1.0.1
1)将新号码添加到目录中>
2)搜索联系人
0)退出
您想做什么?:1
def name_number():name = input(“给新联系人的名字:”)number = input(“给新联系人的名字:”)返回名称def directory():search = input(“ Input您的名字...
您的while循环只会运行一次(甚至不会一直运行到结束),因为您在询问了“您想做什么”后显式中断,程序将结束...