我想在新的本地变量中将CustomerId值分配给AccountId值。我怎样才能做到这一点?

时间:2019-06-15 06:47:34

标签: python-3.x

我正在用字典开发代码。我想在新的本地变量中将CustomerId的值分配给AccountId(我必须在其他地方使用新的本地变量)。有什么方法可以做到吗?

Customer={}
def add_customer():
    while True:
        CustomerId=eval(input("Enter id for customer:"))
        if CustomerId in Customer:
            print("ID already assinged to another customer")
        else:
            CustomerName=(input("Enter customer name:"))
            CustomerCNIC=input("Enter CNIC of customer:")
            CustomerAge=input("Enter age of customer:")
            Customer[CustomerId]=[CustomerName,CustomerCNIC,CustomerAge]
        break
Account={}
def add_account():
    while True:
        AccountId=eval(input("Enter account id:"))
        if AccountId in Account:
            print("ID already assigned to another account holder")
        else:
            AccountType=input("Enter account type:")
            AccountBalance=input("Enter account balance:")
            Account[AccountId]=[AccountType,AccountBalance]
        break

0 个答案:

没有答案