Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Dictionary Built-in Functions

Here are the built-in functions that deal with dictionaries.

len ( object ) → integer

Return the number of items of a sequence or mapping.

dict ( valList ) → dictionary

Each element of the list must be a 2-element tuple; create a dict with the first element as the key and the second element as the value. Note that the zip function produces a list of 2-tuples from two parallel lists.

dict( [('first',0), ('second',1), ('third',2)] )

{'second': 1, 'third': 2, 'first': 0}
dict( zip(['fourth','fifth','sixth'],[3,4,5]) )

{'sixth': 5, 'fifth': 4, 'fourth': 3}

  Published under the terms of the Open Publication License Design by Interspire