Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Zaineb Chouhdry'
- file = open("rawdata.txt", mode="r", encoding="utf8")
- countryIncomes = dict()
- countrySets = dict()
- ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- for letter in ascii_uppercase:
- countrySets[letter] = []
- for line in file:
- info = line.split(":")
- index = info[0]
- country = info[1].replace("\n", "")
- income = info[2].replace("\n", "")
- countryIncomes[country.upper()] = income
- firstLetter = country.upper()[0]
- countrySets[firstLetter].append(country.upper())
- while True:
- user_input = input("Enter an initial or a country name: ").upper()
- if user_input == "QUIT":
- break
- if len(user_input) == 1: #initial
- print(countrySets[user_input])
- elif len(user_input) > 1: #possibly country name
- if user_input in countryIncomes:
- print(countryIncomes[user_input])
- else:
- print("Does not exist")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement