Find age by name in a dictionary

Report a typo

Given a dictionary where the keys are names and the values are ages, write a program that takes a name as input and prints the corresponding age if the name exists in the dictionary, otherwise it prints 'Not found'.

Sample Input 1:

Alice
{'Alice': 25, 'Bob': 30, 'Charlie': 35}

Sample Output 1:

25

Sample Input 2:

David
{'Alice': 25, 'Bob': 30, 'Charlie': 35}

Sample Output 2:

Not found
Write a program in Python 3
def get_age(name, ages):
# Write your code here

name = input()
ages = eval(input())
print(get_age(name, ages))
___

Create a free account to access the full topic