Advertisements
Advertisements
Question
What will be the output of the following Python code?
my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"}
print(my_dict.get("profession", "Not Specified"))
Options
Alicia
DELHI
None
Not Specified
MCQ
Advertisements
Solution
Not Specified
Explanation:
The key "profession" does not exist in the dictionary.
The .get() method returns the default value "Not Specified" when the key is missing.
shaalaa.com
Is there an error in this question or solution?
