More Types Dictionary Functions section, quiz one three | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

More Types Dictionary Functions section, quiz one three

Why I get this error whenever I change the value of primes[4] to a number such as 3 or 2. It works with numbers 1 and 4 though. I don't know why? Just confused. primes = {1: 2, 2: 3, 4: 7, 7:17} print(primes[primes[3]]) I get this error: "Traceback (most recent call last): File "C:/Users/Python/SoloLearn/sololearn3.py", line 2, in <module> print(primes[primes[3]]) KeyError: 3" Thanks

19th Apr 2017, 9:39 PM
Mohamed Zeid
2 Answers
+ 7
You only have the following keys in your dictionary: 1, 2, 4 and 7. As you can see 🔑 Key 3 is non existent.
19th Apr 2017, 10:06 PM
Ismail
Ismail - avatar
+ 1
could it be that there is no key for the number 3?
19th Apr 2017, 10:01 PM
Edward