Instructions
Requirements and Specifications
- Import the country lists from the other two modules
- Do not allow any unhandled errors.
- Include a comment header and comments throughout the code
- Use the ‘standard’ method of naming variables
- Sort the results list in ascending order
- Format the output so it is in two columns
- Write the code neatly
- Display the results neatly
Source Code
from countries_confirmed_start import *
from countries_worked_start import *
# Fore ach country we worked with, filter and select
# only those that did not confirm
unconfirmed_countries = []
for country in worked_list:
if country not in confirmed_list:
unconfirmed_countries.append(country)
# Sort the results in ascending order
for i in range(len(unconfirmed_countries) - 1):
for j in range(i + 1, len(unconfirmed_countries)):
if unconfirmed_countries[i] > unconfirmed_countries[j]:
country = unconfirmed_countries[i]
unconfirmed_countries[i] = unconfirmed_countries[j]
unconfirmed_countries[j] = country
# Print in 2 columns right justified
next_column = 0
for country in unconfirmed_countries:
print(str(country[0]).rjust(30), end="")
next_column += 1
if next_column % 2 == 0:
print()
# Print in 2 columns left justified
print("\n")
next_column = 0
for country in unconfirmed_countries:
print(str(country[0]).ljust(30), end="")
next_column += 1
if next_column % 2 == 0:
print()