Jun-10-2018, 11:50 AM
I can think of couple of ways - but none of them is recommended.
Use dictionaries:
Use dictionaries:
currencies = {'US': 'US$', 'UK': '£'} country_name = 'US' print(currencies[country_name])and you get
Output:US$
PS The name you use are un-Pythonic; Pythonistas customarily use snake-style names for variables - see PEP-8
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.