Reputation: 25
account = {"USD": 10, "HKD": 1000}
for key in account.keys():
print(key)
I would like the output to be like:
In my full program, there are other account with different number of currencies, so I cannot fix 1./2. before keys. I have tried enumerate(), but it can't be used while accessing keys from dictionary.
Upvotes: 0
Views: 36
Reputation: 680
I believe this is what you want.
account = {"USD": 10, "HKD": 1000}
for n, key in enumerate(account, start=1):
print(f'{n}. {key}')
Upvotes: 1