【发布时间】:2020-03-12 01:04:55
【问题描述】:
我正在调用字典中的函数。在下面的代码中,select.get 没有按预期工作。如果inum = 2,它仍然会执行login()。
感谢任何帮助找出问题所在!
def menu():
print("Choose\n1.Log in\n2.Exit")
inum = input()
select = {
1: login(),
2: exit(),
}
select.get(inum, menu())
def login():
guess = ""
acct = "12345"
oog = 3
out = 0
while guess != acct:
if oog == out:
print("no trys left")
input()
exit()
print((str(oog)) + "trys left " + "\nEnter Password here: ")
guess = input()
oog = oog - 1
menu()
【问题讨论】:
-
当您分配给
select时,您正在调用login()和exit()。
标签: python function dictionary select