Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
I run and welcome in this new video.
In this video, we're going to talk about dictionaries and dictionary in Python is a very interesting
object.
It will also allow us to store different value in a same verbal as for the list.
But instead of the list, a dictionary is not indexing by number from zero to end, for example.
Indeed, when you create a dictionary, you need to put the value in the dictionary.
And for each venue, you need to put the associate key, which is a string containing the name of this
value, and it is name the key of the value in the dictionary.
Very, very important things to note, which is that in a dictionary, you can only put a key one time.
So let us begin to code something for the dictionary.
If I want to intonation a nympho dictionary, I will put the name of their variable and a 90 per of
brothels.
If I want to incised a dictionary with this time value, we need to put
the coin of this value and then the value itself.
So for each value, we need to specify.
So.
The venue and the key associated to this venue, and it is important to note, puts the same key military
part time, because if
I put the same key more than one time, I would have an issue.
For example, if I want to
put that so.
We can see that we have met three values here, and it is not an issue, but it is more.
Problematic than usual issue, because if you don't know how a dictionary work, you will have some
error when you are going to could and if you use a dictionary in a rhythmic trading strategy, you can
lose money.
So while we have only two value here instead of three sets, initially, it is because when you put
a key two times, Python takes only the last value.
So if I put here under him, I will have I'm doing for Tesla.
So the first venue he.
He's not taking into account by Python, so.
I will delete this line.
And now we are going to add some value in a dictionary, so it is very simple to do it.
We need to specify in a pair of brackets the key of the venue.
And then we put just the value that we won't have to the dictionary.
Then we can also change of venue, for example, if I want to change the value of Microsoft, I have
just to do exactly the same could because if.
The key is not in the dictionary.
It will create a new venue, but have never seen before.
If the venue is already in the dictionary, it will only change the value.
So if I put three firms in here, it just change the value of Microsoft.
So if you want to extract the price, you need to put the name of the dictionary, then a pair of brackets.
And in this bear bracket, the name of the key associate to the value that you want to extract from
the dictionary.
So.
And we can also see how to delete a value
and to do it is exactly the thing has for the list.
So we used to then operator and then you put the name of the dictionary, then a pair of brackets and
instead of their number from the list, we need to put the key for the dictionary.
So now we are going to see very quickly two interesting function for the dictionary, which are keys
and values.
The key function, which allows us to extract all the key in a dictionary, and it is very interesting
some time, for example, to understand that the number of the venue in a dictionary or to have more
information about this dictionary because the key is a string so we can extract some information.
For example, here, if we extract the key, we can understand that these dictionary contain price inside
of a list.
If we extract the index, we have zero one two three four five, etcetera, and then we can extract
also the value, this time using the function of ventures.
So again, we have seen a lot of things, and it is very important to play with this method to really
master it.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.