-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiple Lists.py
More file actions
64 lines (44 loc) · 1.61 KB
/
Copy pathMultiple Lists.py
File metadata and controls
64 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
bank_accounts = []
balances = []
name_account = None
new_balance = -1
index = -1
index_2 = -1
print("Enter the names and balances of bank accounts (type: quit when done) ")
while name_account != "quit":
name_account = input("What is the name of this account? ")
if name_account != "quit":
new_balance = float(input("What is the balance? "))
bank_accounts.append(name_account)
balances.append(new_balance)
if name_account == "quit":
print("\nAccount Information: ")
for account in bank_accounts:
index += 1
amount = balances[index]
print(f"{index}. {account} - ${amount}")
total_balance = sum(balances)
print(f"\nTotal: ${total_balance:.2f}")
average = total_balance / len(balances)
print(f"Average: ${average:.2f}")
highest_name = None
highest_balance = -1
for i in range(len(bank_accounts)):
account = bank_accounts[i]
balance = balances[i]
if balance > highest_balance:
highest_balance = balance
highest_name = account
print(f"Highest balance: {highest_name} - ${highest_balance:.2f}")
change_account = "yes"
while change_account == "yes":
change_account = input("\nDo you want to update an account? ")
if change_account == "yes":
index_number = int(input("What account index do you want to update? "))
new_amount = float(input("What is the new amount? "))
balances[index_number] = new_amount
print("\nAccount Information: ")
for account in bank_accounts:
index_2 += 1
amount = balances[index_2]
print(f"{index_2}. {account} - ${amount}")