+ 1

Intermediate Python Dictionary Functions

I can get 4/6 tests passed, however, I am not sure what I am doing wrong here. The code is supposed to take the country name as input and output the corresponding key. If the country is not present, it is supposed to print 'Not Found'. Here is my code: data = { 'Singapore': 1, 'Ireland': 6, 'United Kingdom': 7, 'Germany': 27, 'Armenia': 34, 'United States': 17, 'Canada': 9, 'Italy': 74 } print(data.get(input(), 'Not Found'))

12th Oct 2021, 4:54 PM
Josh Haefner
Josh Haefner - avatar
2 Answers
+ 5
Hi Josh! We don't see any error in your code. So, we can assume that the problem is in output string "Not Found". Please double check it's in a correct format. Upper , lower cases matter.
12th Oct 2021, 5:01 PM
Python Learner
Python Learner - avatar
+ 3
if has to be "Not found"
12th Oct 2021, 5:08 PM
Lothar - avatar