Is this possible with dictionaries?


When making a dictionary, is it possible to pull numerous numbers (or names) at the same time?

>> residents = {‘Puffin’ : 104, ‘Sloth’ : 105, ‘Burmese Python’ : 106}
>> print residents[‘Puffin’] #This prints 104

but is it possible to do this:

>> print residents[‘Sloth’, ‘Burmese Python’] #So that my output displays 105 106

Basically I am asking if I needed to look up numerous numbers do I have to print each individually or can I simply put numerous names in the [ ]?

I understand this can be done by making a function but can I do that without the need of a function?


Not possible without an intermediary function to separate them and queue them up for querying.

>>> for i in residents:
	print (i, end=" ")

Puffin Sloth Burmese Python 


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