Why is this python code gives me a key error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this python code gives me a key error?

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

11th Nov 2020, 7:09 AM
Model Pilot
Model Pilot - avatar
2 Answers
+ 6
Because there is no key as ['a','b'] print(aLst['a']) print(aLst['b'])
11th Nov 2020, 7:16 AM
Avinesh
Avinesh - avatar
+ 1
Add fact you can't have two key to one data
11th Nov 2020, 8:04 AM
George S Mulbah II
George S Mulbah II - avatar