A python dictionary is a data structure similar to an associative array found in other programming languages. An array or a list indexes elements by position. A dictionary, on the other hand, indexes elements by keys which can be strings. Think of a dictionary as unordered sets of key-value pairs. In this article, we introduce you to working with python dictionaries. Creating a Dictionary There are several ways of creating a dictionary. The simplest uses brace initialization, with a syntax reminiscent of JSON. users = {'firstname': 'John', 'lastname': 'Smith', 'age': 27} You can use numbers too as the keys. However,...
Read the full article: How to Properly Use the Python Dictionary
from MakeUseOf http://ift.tt/2uhZpxY
via IFTTT
No comments:
Post a Comment