Accessing a list inside a dictionary


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at>
https://www.codecademy.com/courses/learn-python/lessons/student-becomes-the-teacher/exercises/lesson-number-one-?action=lesson_resume

I slightly deviated from what the instructions were but in the example code they displayed a list inside the dictionary, this is the code I wrote.
Add_two = {
‘One’ : ‘three’,
‘Seven’ : ‘Ten’,
‘Thirteen’ : [15,‘fifteen’]
}

print Add_two[“Thirteen”[0]]

<In what way does your code behave incorrectly? Include ALL error messages.>
Traceback (most recent call last):
File “python”, line 7, in
KeyError: ‘T’

I am fairly sure that for some reason the T is related to the “thirteen” because if the T is lower case then the error message displays a lower case t and vice versa

<What do you expect to happen instead?>
I expected for the code to display the first integer in the list

```python

Replace this line with your code.

<do not remove the three backticks above>

#2

Hi @sadmep,

print Add_two[“Thirteen”[0]]

… should be …

print Add_two[“Thirteen”][0]

#3

oh, thanks for the help :smiley:


#4