+ 1
How do I fix this
data = { 'Singapore': 1, 'Ireland': 6, 'United Kingdom': 7, 'Germany': 27, 'Armenia': 34, 'United States': 17, 'Canada': 9, 'Italy': 74 } x = input() print(data.get(x)) if x not in data : print("Not found")
1 Answer
+ 7
Put it into if else logic
data = {
'Singapore': 1,
'Ireland': 6,
'United Kingdom': 7,
'Germany': 27,
'Armenia': 34,
'United States': 17,
'Canada': 9,
'Italy': 74
}
x = input()
if x not in data :
print("Not found")
else:
print(data.get(x))
Or use exit to exit program when you didn't found it there
data = {
'Singapore': 1,
'Ireland': 6,
'United Kingdom': 7,
'Germany': 27,
'Armenia': 34,
'United States': 17,
'Canada': 9,
'Italy': 74
}
x = input()
if x not in data :
print("Not found")
quit()
print(data.get(x))