So I'm writing a program which is a simple currency converter. I'm trying to validate the data so if you type in the wrong data type you are asked to type it again.
GBP_USD = 1.57
print('The current exchange rate is',GBP_USD)
change = input('Would you like to change this?(Y/N) ')
if change.lower() == 'y':
GBP_USD = input('New Rate: ')
while True:
try:
float(GBP_USD)
break
except ValueError:
print('That is not valid.')
GBP_USD = input('New Rate: ')
continue
while (change.lower() != 'y') or (change.lower() != 'n'):
print('Please enter Y or N.')
change = input('Would you like to change this?(Y/N) ')
if change.lower() == 'y':
GBP_USD = float(input('New Rate: '))
break
money = float(input('Money: '))
exchange = money * GBP_USD
rounded = ceil(exchange * 100) / 100.00
print('Dollars:',rounded)
This is what I get in the shell
The current exchange rate is 1.57
Would you like to change this?(Y/N) y
New Rate: three
That is not valid.
New Rate: 4
Please enter Y or N.
Would you like to change this?(Y/N) n
Please enter Y or N.
Would you like to change this?(Y/N) n
Please enter Y or N.
Would you like to change this?(Y/N) n
Please enter Y or N.
Would you like to change this?(Y/N) n
Please enter Y or N.
Would you like to change this?(Y/N) y
New Rate: 6
Money: 4
Dollars: 24.0
Would you like to quit?(Y/N)
Please help me I'm really confused :(