This next part is key


It looks like the value stored under "Sloth" was not printed.

# 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

# Your code here!
print residents['Sloth'and 'Burmese Python']


There is no such key as ['Sloth'and 'Burmese Python']. The keys you have are ['Puffin'], ['Sloth'], and ['Burmese Python'].


@datfatcat thanks for your help


could only make work if each was called on a separate line:

print residents['Sloth']
print residents['Burmese Python']

is this the only way? or can you call multiple keys on one line such as:

print residents['Sloth'] and ['Burmese Python']


print residents['Sloth', 'Burmese Python']

or another way?


If you want the console to display:


Then it is best to do it on separate lines.
If you want to print multiple keys on one line so console looks like this:

105 106

Simply do

print residents['Sloth'], residents['Burmese Python']


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