Printing Two values from dictionary with one print code?


Was just wandering if there is a way of printing two values from a dictionary in the same print code line?

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

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

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


you can only retrieve a single value with a single key, so you would simply need to tell print to print two items:

print dictionary[key1], dictionary[key2]


Okay thanks for that


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