This next part is key


#1

Assigning a dictionary with three key-value pairs to residents:

residents = {'Puffin' : 104, 'Sloth' : 105, 'Burmese Python' : 106}

print residents['Puffin'] # Prints Puffin's room number

print resident ('Solth'105, 'Brumese Pyhton 106')

Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: invalid syntax (python, line 6)


#2

here:

print residents['Puffin'] # Prints Puffin's room number

we get Puffin's room number/value, use the same syntax (square brackets) to retrieve the room numbers of Sloth and Brumese Pyhton


#3

sorry I still don't get it you want me to print 'Puffin' and then print the number


#4

no, this shows how to print the number (value) belonging to Puffin (key)

you need to print the number belonging to Solth and Brumese Pyhton resident, for which you need the same syntax


#5

oh ok thank you just have to do the same thing like 'Puffin'


#6

yes, dictionaries consist of keys and values. If you want to retrieve a value of a dictionary we have the following general syntax:

dictionaryName[keyName]

the exercises asks you to retrieve the room numbers (values) of sloth and Brumese Pyhton (keys)


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.