For my university python course I have an assignment which asks:
Create a change-counting game that gets the user to enter the number of coins necessary to make exactly two dollars. Design an algorithm, express it in pseudocode, and then use it to implement a Python program that prompts the user to enter a number of 5c coins, 10c coins, 20c coins, 50c coins, $1 coins and $2 coins. If the total value of those coins entered is equal to two dollars, then the program should congratulate the user for winning the game. Otherwise the program should display a message advising that the total was NOT exactly two dollars, and showing how much the value was above or below two dollars.
I understand how to implement the program but im having trouble trying to apply a variable to the user inputs without repetition.
I would like to use a FOR loop like so:
def main():
for coin in ['5c','10c','20c','50c','$1','$2']:
int(input("Enter the number of " + coin + " coins you wish use: "))
#Call the main function
main()
But how do I assign a new variable to each user input every time it loops?
Python 2.xorPython 3.x.