Printing Two values from dictionary with one print code?


#1

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']```

#2

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]

#3

Okay thanks for that


#4

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