Last modified: Jan 10, 2023 By Alexander Williams
How to Get The Currency of any Country in Python
Getting the country's currency is one of the things that you'll use in your eCommerce app.
So to do that we need to use the Countryinfo library.
Let's get started.
Install the CountryInfo library
Instaling CountryInfo via pip:
pip install countryinfo
Syntax
CountryInfo(country).currencies()
notice: you'll get the result as list
Getting the currency of any country
In the code below, we'll understand how to get the currency of a specific county.
from countryinfo import CountryInfo
#country
country = input('Choose a country: ')
#capital
currencies = CountryInfo(country).currencies()
#print
print(currencies)
output
Choose a country: germany
['EUR']
Choose a country: united states
['USD', 'USN', 'USS']