Afrikaans
Akan
Albanian
Amharic
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
Welcome back.
I kept mentioning this key term ignorable but what does it really mean.
It arable.
You're going to hear that over and over in Python programming and other programming languages as well.
And as we discussed a little bit in the previous video irritable simply means it is an object or a collection
that can be iterated over.
So again and it arable can be a list can be a dictionary can be a topple can be a set.
It's a collection of items.
We also saw that a string could be irritable.
Now these things are ignorable.
Why.
Because if they can be iterated that is iterated means that we can go one by one to check each item
in the collection
and you're going to hear this over and over when talking to Python programmers.
So you want to make sure that you have that vocabulary you're iterating over something you're looping
over something so terrible is the noun and iterated or iterate is the action of iterating over and editable.
I know it's a little confusing now.
Many objects in python like I said are edible but there's a few special ones that we haven't covered
yet specifically dictionary.
We saw how lists topples sets and strings can be iterated.
But what about an object.
Let's say we have an object here and this object will be users and users or user will have a name of
column will have age of five thousand six goblins PRETTY OLD AND THEN WE'LL SAY CAN SWIM Gollum let's
say cannot swim.
False.
What if we use this object right here for item in user and we print right here.
The item what do you think will happen.
Let's run this well.
I get an error because I forgot a cell many call in here and we don't why he goes we want semicolon
and then obviously this needs to be a string as well.
Now if I click a run here look at that I get name age and can't swim.
So I've printed the keys of the dictionary.
Now this dictionary we have the keys.
That's great.
But what if I wanted actually the values.
Is there a way to do this well dictionaries have three methods that are really really useful when we
want to loop over their keys and values.
The first one is items and with items when I do this and I click run you'll see that I get the key value
pair in a table and this is a very common pattern that you'll see a lot another one that we have is
the values and guess what that does that gives us the values of the dictionary and we saw that user
just leaving it blank.
Gives us the keys but we have a method that is more descriptive and allows us to show exactly what we
want to do which is keys.
And if we run this you'll see that I'm able to iterate over the keys in these three methods are very
common and you're gonna use them a lot in your programming career.
So make sure you take note of them items values and keys.
It allows us to iterate over dictionaries But another interesting thing they can do and another common
pattern when iterating over dictionaries is what if you want to print for example separately the items
name and column.
So right now we're returning a Tupperware and we saw that we can do trouble unpacking.
Right.
I can say key value equals item and then just print key value.
If I run this you see that I'm able to print these but there's actually a shorthand way of being able
to do this in here in the for loop.
I can say key value and just completely avoid this entire line and if I run this.
There you go.
It still works.
And this again is a very common pattern where if you're collecting the items of a dictionary you can
separate them into key and value or you might even see shorthand K and the again.
These can be any variables that you want you can name them whatever helps your code be more readable
by the way just for fun let's say in the last line here.
I want to iterate over the number 50 what do you think will happen then if I click Run sorry.
Name the name key.
Oh I get an error here because I haven't changed.
So let's change these back.
That's not the era I was expecting.
The error I was expecting was this type error int object is not ignorable.
Now this error should make sense now because I've said it over and over.
Why is it not adorable.
Well because it's not an object that can be iterated over.
It's not a collection of items because we learned that in Python these are editable.
I'll see in the next video by.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.