Computer Science

Predict the output

a = {'a':1, 'b':2, 'c':3}
print(a['a','b'])

Python Dictionaries

7 Likes

Answer

Output
KeyError: ('a', 'b')  
Explanation

a is a dictionary containing three key-value pairs.
a['a','b'] will throw an error since given key ('a','b') is not present in dictionary a.

Answered By

3 Likes


Related Questions