Answer:
See Explanation
Step-by-step explanation:
The question has missing details;however, I'm able to pick the following points from the question
- There's supposed to be a list of loan amounts
- There's also supposed to be a list of countries that took loans. This list will correspond to the loan list
Having said that, the question can be solved in two ways.
- I prompt the user to enter loan amounts and corresponding country
- I assume any value for the loan amounts and the country
I'll answer this question using the first method and the solution is as follows (See Comments for line by line explanation):
#This line prompt user for number of countries
n = int(input("Number of countries: "))
#This initializes an empty list for loan amounts
loan_amounts = []
#This initializes an empty list for country
country = []
#The following iteration gets names of countries and their respective loan amounts
for i in range(0,n):
country_name = input("Name of country: ")
loan = int(input("Loan Amount: "))
country.append(country_name)
loan_amounts.append(loan)
#This gets the maximum loan
max_loan = max(loan_amounts)
#This gets the index of the maximum loan
iindex = loan_amounts.index(max_loan)
#This gets the country with the maximum loan
max_country = country[iindex]
#This gets the minimum loan
min_loan = min(loan_amounts)
#This gets the index of the minimum loan
iindex = loan_amounts.index(min_loan)
#This gets the country with the minimum loan
min_country = country[iindex]
#This prints the country with the maximum loan and the loan amount
print(str(max_country)+": "+str(max_loan))
#This prints the country with the minimum loan and the loan amount
print(str(min_country)+": "+str(min_loan))