Skip to content

Instantly share code, notes, and snippets.

@gbozee
Created January 20, 2018 15:02
Show Gist options
  • Save gbozee/fa2e263a8b77f0931ff5f84e91286877 to your computer and use it in GitHub Desktop.
Save gbozee/fa2e263a8b77f0931ff5f84e91286877 to your computer and use it in GitHub Desktop.
Python Meetup Lesson Gist
#Twitter @Beee_sama
#Slack pythonnigeria.slack.com @B33s@m@
rates = [{
'country': ['USA'],
'currency': 'USD',
'rate': 360
},
{
'country': ['UK'],
'currency': 'GBP',
'rate': 500
},
{
'country': [],
'currency': 'BTC',
'rate': 4_551_124.12
},
{
'country': ['Ghana'],
'currency': 'GHS',
'rate': 78.51,
},
{
'country': ['France','Germany','Italy','Spain'],
'currency': 'EUR',
'rate': 440,
},
]
print("Welecome to our meetup python application")
print('We currently support only Naira (Nigerian Currency)')
currency_or_country = input("Please type a currency/country: "
)
result = None
kind = None
for record in rates:
if currency_or_country.lower() == record['currency'].lower():
result = record['rate']
kind = "currency"
break
similar_case_countries = []
for country in record['country']:
similar_case_countries.append(country.lower())
if currency_or_country.lower() in similar_case_countries:
result = record['rate']
kind = 'country'
break
if result:
print("The rate for {} which is a {} is {}".format(currency_or_country,kind, result))
else:
print("Sorry! we couldn't find your currency/country")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment