Python Forum
currency converter using forex-python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
currency converter using forex-python
#8
Example like this.
try:
    cr = CurrencyConverter()
    amount = float(input("Please enter the amount you want to convert: "))
    from_currency = input("Please enter the currency code that has to be converted: ").upper()
    to_currency = input("Please enter the currency code to convert: ").upper()
    print(f"You are converting {amount} {from_currency} to {to_currency}.")
    output = cr.convert(amount, from_currency, to_currency)
    print(f"{amount} {from_currency} equals {output} {to_currency}")
except ValueError:
    print("Invalid input! Please ensure the amount is a number.")
except Exception as error:
    print(f"An error occurred: {error}")
Reply


Messages In This Thread
RE: currency converter using forex-python - by snippsat - Mar-08-2024, 10:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,467 Jun-29-2023, 11:57 AM
Last Post: gologica
  Help with basic weight converter PythonSquizzel 3 1,502 Jun-29-2022, 02:42 PM
Last Post: deanhystad
  xml extract currency 3lnyn0 5 1,763 Apr-30-2022, 10:29 AM
Last Post: snippsat
  calculate daily return in percent in forex as to some strategy? alen 1 2,251 Mar-12-2021, 10:03 AM
Last Post: buran
  Converter Souls99 2 2,437 Aug-01-2020, 01:27 AM
Last Post: Souls99
  Help me get this image converter code working? NeTgHoSt 0 2,127 Jul-14-2020, 10:36 PM
Last Post: NeTgHoSt
  Currency converter Scott 5 3,099 Jun-14-2020, 11:59 PM
Last Post: Scott
  How to use 2to3.py converter under Windows OS samsonite 2 7,384 Mar-02-2019, 05:49 AM
Last Post: samsonite
  Currency formatting the third element in a 2D list RedSkeleton007 3 3,243 Mar-09-2018, 12:53 PM
Last Post: j.crater
  Can't get a downloaded file converter to work Godotisnothere 1 3,228 Jan-24-2017, 06:01 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020