This script allows users to convert a base currency to multiple other currencies using the Free Currency API. The script continuously prompts the user for a base currency and displays the conversion rates for a predefined list of currencies.
- Converts a base currency to multiple other currencies.
- Uses the Free Currency API to fetch the latest conversion rates.
- Continuously prompts the user for a base currency until they choose to quit.
- Python 3.x
requests
module (pip install requests
)- Free Currency API key
-
Clone the repository (if applicable) or download the script file.
-
Install the required module:
pip install requests
-
Edit the script:
- Replace
'fca***
with your Free Currency API key. - Optionally, modify the
CURRENCIES
list to include the currencies you want to convert to.
- Replace
-
Run the script:
python script_name.py
-
Use the script:
- Enter the base currency code when prompted (e.g.,
USD
,EUR
). - Enter
q
to quit the script.
- Enter the base currency code when prompted (e.g.,
- The script defines the API key, base URL, and a list of target currencies.
- The
convert_currency
function constructs the API request URL, fetches the conversion rates, and returns the data. - The script continuously prompts the user for a base currency and displays the conversion rates for the target currencies.
- The user can quit the script by entering
q
.
- Ensure you have a valid API key from the Free Currency API.
- The script handles invalid currency inputs by displaying an error message and prompting the user again.