Looking for python help: How do i make a while loop reset and allow the user to input new information
You mean reset the values inside a loop? Probably need some conditional statement (if) to see when this needs to happen.
ooh ok so you can put an if statement inside of a while ?
``` print('1. Argentine Peso') print('2. Brazilian Real') print('3. British Pound') print('4. European Euro') print('5. Indian Rupee') print('6. Japanese Yen') print('7. Russian Ruble') print('8. Other \n') usd = 0 usd = eval(input('Enter amount to convert (<= 0 to exit): ')) peso = usd * 8.48 real = usd * 2.46 pound = usd * 0.62 euro = usd * 0.79 rupee = usd * 61.59 yen = usd * 109.49 ruble = usd * 39.45 num = eval(input('Enter Selection: ')) while num == 1: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(peso,2)) + ' Argentine Pesos.') while num == 2: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(real,2)) + ' Brazilian Real.') while num == 3: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(pound,2)) + ' British Pound.') while num == 4: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(euro,2)) + ' European Euro.') while num == 5: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(rupee,2)) + ' Indian Rupee.') while num == 6: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(round(yen,2)) + ' Japanese Yen.') while num == 7: num = num + 1 print('' + str(usd) + ' US Dollars converts to: ' + str(ruble) + ' Russian Ruble.') while num == 8: num = num + 1 currency = input('Enter current to convert to: ') amount = eval(input('Enter the conversion factor for ' + currency + ': ')) random = usd * amount print('' + str(usd) + ' US Dollars converts to: ' + str(random) + ' ' + currency + '.') ```
this is currently my code, it runs fine but i need it to only use one of the options at a time, then to restart and allow the user to start over and enter a new number and choose a new option
@e.mccormick
You can even put a while inside a while.
hmm arlight, let me give it a shot
Yah, typically what you are doing would be done with ifs or in some languages with a select/case.
yeah i just figured i was supposed to use while because thats what we were going over in class and thought thats what this assignment was supposed to teach us.
Well, if the entire program is meant to run multiple times, you could use a while loop around it all and then put the if stuff inside it.
oooh! ok so maybe thats what im supposed to do
that makes sense!
thank you, ill use the info you gave me. i gotta go, thanks again
Kk. It is a pretty simple concept, so you should be able to figure it out, but sometimes a diagram helps. http://www.cs.kent.edu/~batcher/CS10051/loops.jpg There is one I found with an image search. The set of algorithmic operations to be performed is the conversion and output stuff.
Join our real-time social learning platform and learn together with your friends!