Question: I'm stuck on what to do next for my PYTHON assignment for class. The program we're suppose to make is to have the user enter

I'm stuck on what to do next for my PYTHON assignment for class. The program we're suppose to make is to have the user enter a choice, 1-4.

1. Asks the name of a country and displays the currency and exhange rate of said country.

2. Converts currency from one country to another/

3. Displays the country's from A-Z

4. is suppose to sort the country's from the lowest exchange rate to the highest.

f=open('CurrencyExchange02082020.txt') print ('1.View Country, 2. Convert, 3. List all countries in A-Z, 4. List all countries money-wise') choice1=input ('Which operation do you wish to choose? ') if choice1 == "1": country=input('Enter the name of a country: ') country=country.lower() d={} for line in f: line=line.strip() data=line.split(',') if data[0].lower() not in d: d[data[0].lower()]=[data[1],data[2]]

if country: if country in d: print('Currency: ',d[country][0]) print('Exchange rate: ',d[country][1]) else: print('Country not found in the list') else: print('Enter a country name:')

if choice1 == "2": f=open('CurrencyExchange02082020.txt') d={}

for line in f: line=line.strip() data=line.split(',') if data[0].lower() not in d: i=float(data[2]) d[data[0].lower()]=[data[1],i]

country1=input('Enter name of first country: ') country1=country1.lower() country2=input('Enter name of second country: ') country2=country2.lower() amount=int(input('Amount of money to convert: ')) if country1 in d: if country2 in d: exc=d[country1][1] exc2=d[country2][1] mny=d[country1][0] mny2=d[country2][0] amt=amount * (exc2 /exc) print('%d %s from %s equals %.2f %s from %s' %(amount,mny,country1.capitalize(),amt,mny2,country2.capitalize())) else: print('%s is not in the list' %country2) print('Try again') else: print('%s is not in the list' %country1) print('Try again')

if choice1 == "3": file_name = open('CurrencyExchange02082020.txt') new_list = [] for items in file_name: if items != ' ': items = items.replace(" ", "") new_list.append(items) new_list = sorted(new_list) for i in new_list: print (i)

I'm stuck on how to actually do the 4th option. Could someone point me in the right way please?

and here is the .txt file that it reads

United States of America,USD,1 Aruba,Florin,1.8 Argentina,Peso,88.17 Australia,Australian Dollar,1.3 Austria,Euro,0.83 Bahrain,Dinar,0.38 Belgium,Euro, 0.83 Brazil,Real,5.34 Bitcoin (no country), bitcoin, 0.000023 Canada,Dollar,1.27 Chile,Peso,733.80 China,Yuan,6.44 Czech Rep.,Koruna,21.32 Denmark,Krone,6.17 European Union,Euro,0.83 Finland,Euro,0.83 France,Euro,0.83 Germany,Euro,0.83 Greece,Euro,0.83 Hong Kong,Hong Kong Dollar,7.75 Hungary,Forint,297.25 Iceland,Krona,128.19 India,Rupee,72.87 Ireland,Euro,0.83 Israel,Shekel,3.27 Italy,Euro,0.83 Japan,Yen,105.20

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!