line shift? (baby steps 2)

Artemisio calidusdk at hotmail.com
Mon Aug 23 14:12:30 CEST 2004

```I have done a small currency calculator. It works and I'm very glad.
But...I'd like to have a line shift if user types a wrong choice.
Please, look at the code and output example down here:

# -*- coding: ISO-8859-1 -*-
import string

eudk_currency= 7.47
dkeu_currency= 0.13
usdk_currency= 5.93
dkus_currency= 0.16
euus_currency= 1.19
useu_currency= 0.78

currency_choice= raw_input("Please type DK if you want convert to DKK,
EU if you want to convert to €: ")
currency_str= str(currency_choice).upper()

while currency_str != "EUDK" and currency_str != "DKEU" and
currency_str != "USDK" and currency_str != "DKUS"\
and currency_str != "EUUS" and currency_str!= "USEU":
currency_choice= raw_input("Sorry. At the moment we only support
DKK, Euro and Dollars." + "\n" \
"Type DKEU if you want convert from DKK to €," + "\n" \
"EUDK if you want to convert from DKK to €," + "\n" \
"DKUS if you want to convert from DKK to \$," + "\n" \
"USDK if you want to convert from \$ to DKK," + "\n"
"EUUS if you want to convert from € to \$," + "\n"\
"and USEU if you want to convert from \$ to €: ")
currency_str= str(currency_choice).upper()

amount_int= input("Please type the amount you wish to convert: ")

if currency_str == "DKEU":
result= amount_int* dkeu_currency
print amount_int, "Danish Crowns correspond to", result, "Euro."

if currency_str == "EUDK":
result= amount_int* eudk_currency
print amount_int, "Euro correspond to", result, "Danish Crowns."

if currency_str == "USDK":
result= amount_int* usdk_currency
print amount_int, "Dollars correspond to", result, "Danish Crowns."

if currency_str == "DKUS":
result= amount_int* dkus_currency
print amount_int, "Danish Crowns correspond to", result, "Dollars."

if currency_str == "EUUS":
result= amount_int* euus_currency
print amount_int, "Euro correspond to", result, "Dollars."

if currency_str == "USEU":
result= amount_int* useu_currency
print amount_int, "Dollars correspond to", result, "Euro."
#CODE END

OUTPUT:

Please type DK if you want convert to DKK, EU if you want to convert
to €: sdsd
Sorry. At the moment we only support DKK, Euro and Dollars.
Type DKEU if you want convert from DKK to €,
EUDK if you want to convert from DKK to €,
DKUS if you want to convert from DKK to \$,
USDK if you want to convert from \$ to DKK,
EUUS if you want to convert from € to \$,
and USEU if you want to convert from \$ to €: usdk
Please type the amount you wish to convert: 99
99 Dollars correspond to 587.07 Danish Crowns.

How do I get a line shift before (and/or) after the "Sorry....At the
moment"), so the output is something like:

Please type DK if you want convert to DKK, EU if you want to convert
to €: sdsd

Sorry. At the moment we only support DKK, Euro and Dollars.
Type DKEU if you want convert from DKK to €,
EUDK if you want to convert from DKK to €,
DKUS if you want to convert from DKK to \$,
USDK if you want to convert from \$ to DKK,
EUUS if you want to convert from € to \$,
and USEU if you want to convert from \$ to €: usdk
Please type the amount you wish to convert: 99
99 Dollars correspond to 587.07 Danish Crowns.

OR

Please type DK if you want convert to DKK, EU if you want to convert
to €: sdsd

Sorry. At the moment we only support DKK, Euro and Dollars.

Type DKEU if you want convert from DKK to €,
EUDK if you want to convert from DKK to €,
DKUS if you want to convert from DKK to \$,
USDK if you want to convert from \$ to DKK,
EUUS if you want to convert from € to \$,
and USEU if you want to convert from \$ to €: usdk
Please type the amount you wish to convert: 99
99 Dollars correspond to 587.07 Danish Crowns.

???
Thank you for your patience! :-)

```