cardPayments={}
rowNumber, NumOfCardPayments = 0, len(cardPayments)
for x in range(5):
cardPayments.update({x:x})
print(cardPayments)
print('cardPayments: '+str(NumOfCardPayments)+'\n')
Output:
{0: 0}
cardPayments: 0
{0: 0, 1: 1}
cardPayments: 0
{0: 0, 1: 1, 2: 2}
cardPayments: 0
{0: 0, 1: 1, 2: 2, 3: 3}
cardPayments: 0
{0: 0, 1: 1, 2: 2, 3: 3, 4: 4}
cardPayments: 0
I was hoping that by referencing NumOfCardPayments
to len(cardPayments)
that as cardPayments
dict increased in size so would the int value of NumOfCardPayments
during the for loop, this seems to not be the case.
How can I create NumOfCardPayments
as a variable which is maintained as a reference of len(cardPayments)
?
(Please note, I would not like to simply do NumOfCardPayments+=1
within the for loop)