All language subtitles for 38. Dictionary Methods 2

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

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.