【发布时间】:2020-05-04 04:34:54
【问题描述】:
目标仅使用 python 基础列表、while 循环、if else 的迷你银行模拟。
问题 2. 搜索帐户。 注意我希望我的程序返回匹配名称的相应年龄和余额。提前致谢。
print("""1. Add Account
2. Search Account"
3. Exit \n\n""")
name = []
age = []
balance = []
while True:
choice = input("What is your choice ? : ")
if choice == "1":
name.append(input("Name : "))
age.append(input("Age : "))
balance.append(input("Balance : "))
print("Account Registration Done\n\n")
if choice == "2":
y = input("What is your Account Name ? > : ")
if y in name: # i want my program to return the respective age and balance of the matching name.
print(name[0]) # Here is the issue and i don't know how to fix.Please Kindly enlighten me
print(age[0])
print(balance[0])
else:
print(
f"Your name[{y}] have't registered yet.Please register first")
if choice == "3":
break
【问题讨论】:
-
“我希望我的程序返回新添加的帐户” 是不是一直想要新添加的帐户详细信息或与名称匹配的帐户详细信息?
-
与名称匹配的帐户的详细信息。非常感谢您的评论。
-
您是否可以更新问题以使其清楚?我们已经有了两个答案。
标签: python-3.x list indexing