Hi,
I have in my program a list of lists of variables. These variables change as the program runs. I would like to be able to link meaningful names to the variables. So, say I have a list of quantities of different coins in my possession
where the entries are the quantities of pennies, nickels, dimes, and quarters I have, respectively. Can I assign variable names to the entries so that if, in the course of my program, it simulates a purchase for 5 cents-
I can say
And get the following output?
0
2
Thanks for the help; sorry if my terminology is bad as I am new to programming!
I have in my program a list of lists of variables. These variables change as the program runs. I would like to be able to link meaningful names to the variables. So, say I have a list of quantities of different coins in my possession
Code:
myChange = [0, 0, 0, 1]
Code:
myChange [3] = myChange [3] - 1 myChange [2] = myChange [2] + 2
Code:
print quarters print dimes
0
2
Thanks for the help; sorry if my terminology is bad as I am new to programming!
Comment