Recent Posts

Dictionaries

Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. An empty dictionary without any items is written with just two curly braces, like this: {}.
Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.
For example, with curly braces, we will define our dictionary

But the key is unique, you can not have two different values. It doesn't allow duplicates. Check as well that we have number, strings and boolean values

We can print the name if that is written properly

But when there is a Typo, another value, the result is different

it won't take either a key that doesn't exist..It will provide an error

there is another step, the "get method"

it won't show any error and we will get "none" that means, the absence of value


In this case, we will get the default value

We can update the values as well

We can add new values as well







Get a program that translates a number into word



Now we will try to install emojis in our application using dictionaries. This exercise is similar to the last one but with small differences



It will replace the variable with a emoji...













Dictionaries Dictionaries Reviewed by ohhhvictor on May 08, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.