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
French
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
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
By the way there is actually one more way that we've actually seen in list how to look for an item in
a dictionary remember how in lists we use the keyword in we said something along the lines of Hey is
I in a list that contains I or we even used a string like Hi.
Well you can do the same with dictionaries.
I can say does basket exist in user and let's print this out.
And run and it's going to say yep basket does exists in user.
What about what about the size.
Does that exist.
No that's false.
That does not exist in user.
But here is where it gets really interesting.
And this again is a nother dictionary method that we can use.
And by the way you can see that there's not that many dictionary methods that well dictionaries have.
Luckily we're gonna go over the main ones here though one is called Quis and keys simply checks the
keys.
What are the keys of user.
So if I go Hello here and I click Run well no keys ha sorry on this side not this.
So this is a value.
So if I want to check keys I'd say H which is true but if I want to check a values well in that case
if I do.
Hello I get true it's going to go over or what we call iterate over the values another one that's really
useful is the items and items is special because we've seen keys and values but items actually grabs
the entire item.
So the way we can actually see this is let's just remove and click Run All right.
This is interesting.
I have dict items here and I grab looks like a list and in here we have a bracket basket.
One two three greet hello and H20 but there's some weird syntax here that we haven't seen before and
this is actually a topple.
So we're going to hold off on this and talk about this a little bit more when we talk about our next
data structure but keys values and items is an easy way for us to grab these things for us from our
dictionary let's continue on with other dictionary methods that we might use.
One is a very nice one.
It's called Clear.
And if I run this you'll see that I get an empty dictionary.
What if I just run users dot clear here and run.
User Well it's still an empty object or an empty dictionary so you can see here that clear doesn't actually
return anything.
It doesn't.
Well it is just in place removes whatever the dictionary has.
So it just creates an empty dictionary.
What about copy while a copy allows us to copy a user so that if I print user and user 2 and I click
Run I get two users each.
Keys and values copy.
But if I now let's say clear the first user and I click Run the first user is empty but because I've
copied the second user the second user has the old information and this is a concept that we've talked
about before.
Another useful command and let's just go back to having user is user dot pop which removes a key and
a value from the dictionary.
So in our case let's just say we want to remove the key that is age so I'm going to say h and if I run
this I get 20 because pop returns the value of whatever got removed.
But if I do print user now you'll see that age does not exist anymore because we've popped it off but
pop as you can see removes the actual value or returns the actual value 20.
Here's another really fun one pop item.
And honestly this I having used much but I just think it's a fun one pop item.
If you guessed Well you're not gonna guess oh and that's because I have to make sure I write it properly
with lowercase if I run this would just happened it randomly pops off something one of the keys and
the values in this case age 20 is removed.
So the last item on the dictionary gets removed by remember a dictionary is unordered.
So if this was a massive massive dictionary that well doesn't have any order to it sometimes it removes
some pear as you can see not the last one but some pair of key value so you have to be careful with
this one.
It doesn't necessarily just remove the last thing that you entered but it might be useful on some occasions.
Finally we have something called update an update simply updates as the name suggests a key value so
let's have a look here.
All we have to do is give it a new dictionary so curly brackets and just simply say hey I want to update
age to fifty five fight click Run Oh and I forgot a bracket here.
Let's try that again.
If I click Run.
There you go.
Age got updated but if this was a key that doesn't exist like ages and I click run it will still update
with a new key item.
So this is another really useful method.
All right that's it for dictionaries.
I'll see you in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.