-2

I was hoping to print a key only (and not its value) from the dictionary (listed below): e.g. I want to print Arab Emirates (and not its value):

Country = {'Destination country': 'Zones', 'Arab Emirates': 'Zone 9', 'Argentina': 'Zone 9', 'Austria': 'Zone 8', 'Bahrain': 'Zone 9', 'Belgium': 'Zone 8', 'Brazil': 'Zone 8', 'Brunei Darussalam': 'Zone 5', 'Cambodia': 'Zone 5', 'Canada': 'Zone 4', 'Chile': 'Zone 9', 'China': 'Zone 2', 'Cook Islands': 'Zone 5', 'Croatia': 'Zone 8', 'Cyprus': 'Zone 8', 'Czech Republic': 'Zone 8', 'Denmark': 'Zone 8', 'Estonia': 'Zone 8', 'Fiji': 'Zone 5', 'Finland': 'Zone 8', 'France': 'Zone 7', 'French Polynesia': 'Zone 5', 'Germany': 'Zone 7', 'Greece': 'Zone 8', 'Hong Kong': 'Zone 3', 'Hungary': 'Zone 8', 'India': 'Zone 3', 'Indonesia': 'Zone 3', 'Iran': 'Zone 9', 'Ireland': 'Zone 6', 'Israel': 'Zone 9', 'Italy': 'Zone 7', 'Japan': 'Zone 3', 'Kenya': 'Zone 9', 'Korea': 'Zone 3', 'Kuwait': 'Zone 9', 'Lao': 'Zone 5', 'Macedonia': 'Zone 8', 'Malaysia': 'Zone 3', 'Malta': 'Zone 8', 'Mauritius': 'Zone 9', 'Mexico': 'Zone 9', 'Myanmar': 'Zone 5', 'Nauru': 'Zone 5', 'Nepal': 'Zone 5', 'Netherlands': 'Zone 7', 'New Caledonia': 'Zone 5', 'New Zealand': 'Zone 1', 'Nigeria': 'Zone 9', 'Norway': 'Zone 7', 'Pakistan': 'Zone 5', 'Papua New Guinea': 'Zone 5', 'Peru': 'Zone 9', 'Philippines': 'Zone 5', 'Poland': 'Zone 8', 'Portugal': 'Zone 8', 'Qatar': 'Zone 9', 'Romania': 'Zone 8', 'Russian Federation': 'Zone 8', 'Samoa': 'Zone 5', 'Saudi Arabia': 'Zone 9', 'Serbia': 'Zone 8', 'Singapore': 'Zone 3', 'Slovenia': 'Zone 8', 'Solomon Islands': 'Zone 5', 'South Africa': 'Zone 8', 'Spain': 'Zone 7', 'Sri Lanka': 'Zone 5', 'Sweden': 'Zone 7', 'Switzerland': 'Zone 7', 'Taiwan': 'Zone 3', 'Thailand': 'Zone 3', 'Tonga': 'Zone 5', 'Turkey': 'Zone 8', 'Ukraine': 'Zone 8', 'United Kingdom': 'Zone 6', 'United States': 'Zone 4', 'Vanuatu': 'Zone 5', 'Vietnam': 'Zone 3'}

Thanks a lot in advance.

Lamanus
  • 12,898
  • 4
  • 21
  • 47
DarkKnight
  • 57
  • 5
  • 3
    Possible duplicate of [How to print a dictionary's key?](https://stackoverflow.com/questions/5904969/how-to-print-a-dictionarys-key) – aloisdg Sep 23 '19 at 13:32
  • 3
    More a duplicate of https://stackoverflow.com/questions/8023306/get-key-by-value-in-dictionary – aloisdg Sep 23 '19 at 13:34
  • `Country.keys()` – Marco Milanesio Sep 23 '19 at 13:36
  • Thanks mate. Although, what I am really after is if I can print only 1 specific key. E.g. a user puts in: Arab Emirates as a string and then I want the code to search for Arab Emirates in this Dictionary key and print it. – DarkKnight Sep 23 '19 at 13:39
  • Hello and welcome to SO. May I kindly suggest you do the [official python tutorial](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) ? It will save you a _lot_ of time and pain... – bruno desthuilliers Sep 23 '19 at 13:40
  • "I want the code to" => Sorry but that's not how it works. – bruno desthuilliers Sep 23 '19 at 13:42

1 Answers1

0
Country = {'Destination country': 'Zones', 'Arab Emirates': 'Zone 9', 'Argentina': 'Zone 9', 'Austria': 'Zone 8', 'Bahrain': 'Zone 9', 'Belgium': 'Zone 8', 'Brazil': 'Zone 8', 'Brunei Darussalam': 'Zone 5', 'Cambodia': 'Zone 5', 'Canada': 'Zone 4', 'Chile': 'Zone 9', 'China': 'Zone 2', 'Cook Islands': 'Zone 5', 'Croatia': 'Zone 8', 'Cyprus': 'Zone 8', 'Czech Republic': 'Zone 8', 'Denmark': 'Zone 8', 'Estonia': 'Zone 8', 'Fiji': 'Zone 5', 'Finland': 'Zone 8', 'France': 'Zone 7', 'French Polynesia': 'Zone 5', 'Germany': 'Zone 7', 'Greece': 'Zone 8', 'Hong Kong': 'Zone 3', 'Hungary': 'Zone 8', 'India': 'Zone 3', 'Indonesia': 'Zone 3', 'Iran': 'Zone 9', 'Ireland': 'Zone 6', 'Israel': 'Zone 9', 'Italy': 'Zone 7', 'Japan': 'Zone 3', 'Kenya': 'Zone 9', 'Korea': 'Zone 3', 'Kuwait': 'Zone 9', 'Lao': 'Zone 5', 'Macedonia': 'Zone 8', 'Malaysia': 'Zone 3', 'Malta': 'Zone 8', 'Mauritius': 'Zone 9', 'Mexico': 'Zone 9', 'Myanmar': 'Zone 5', 'Nauru': 'Zone 5', 'Nepal': 'Zone 5', 'Netherlands': 'Zone 7', 'New Caledonia': 'Zone 5', 'New Zealand': 'Zone 1', 'Nigeria': 'Zone 9', 'Norway': 'Zone 7', 'Pakistan': 'Zone 5', 'Papua New Guinea': 'Zone 5', 'Peru': 'Zone 9', 'Philippines': 'Zone 5', 'Poland': 'Zone 8', 'Portugal': 'Zone 8', 'Qatar': 'Zone 9', 'Romania': 'Zone 8', 'Russian Federation': 'Zone 8', 'Samoa': 'Zone 5', 'Saudi Arabia': 'Zone 9', 'Serbia': 'Zone 8', 'Singapore': 'Zone 3', 'Slovenia': 'Zone 8', 'Solomon Islands': 'Zone 5', 'South Africa': 'Zone 8', 'Spain': 'Zone 7', 'Sri Lanka': 'Zone 5', 'Sweden': 'Zone 7', 'Switzerland': 'Zone 7', 'Taiwan': 'Zone 3', 'Thailand': 'Zone 3', 'Tonga': 'Zone 5', 'Turkey': 'Zone 8', 'Ukraine': 'Zone 8', 'United Kingdom': 'Zone 6', 'United States': 'Zone 4', 'Vanuatu': 'Zone 5', 'Vietnam': 'Zone 3'}
ls = list(Country.keys())
print(ls)
Vashdev Heerani
  • 660
  • 7
  • 21