0
National Economic Freedom-Python
Ok, so I was doing this exercise and I wrote this code: data = { 'Singapore': 1, 'Ireland': 6, 'United Kingdom': 7, 'Germany': 27, 'Armenia': 34, 'United States': 17, 'Canada': 9, 'Italy': 74 } entry=input() if entry in data: print(data.get(entry)) else: print("Not Found") I think it is the most adequate answer, and the first four tests are correct but the fifth and the sixth aren't, and they are not shown, so I don't know why it doesn't work, if someone could tell me what's wrong...
5 ответов
+ 4
Your solution is:
data = {
'Singapore': 1,
'Ireland': 6,
'United Kingdom': 7,
'Germany': 27,
'Armenia': 34,
'United States': 17,
'Canada': 9,
'Italy': 74
}
entry=input()
if entry in data.keys():
print(data.get(entry))
else:
print("Not Found")
Because you are specifying that it is in the names of the countries.
I hope you understand me, any doubt ask me.
+ 3
the reason why you struggle is only due to the incorrect spelling of the output message.
if has to be: " Not found". in your code "Found" is spelled with a capital letter, but should be lower case.
^
this is the only issue you have to change.
+ 2
Does this answer your question?
https://www.sololearn.com/Discuss/2902844/?ref=app
0
data = {
'Singapore': 1,
'Ireland': 6,
'United Kingdom': 7,
'Germany': 27,
'Armenia': 34,
'United States': 17,
'Canada': 9,
'Italy': 74
}
name = input()
if name in data:
print(data[name])
else:
print("Not found")