All language subtitles for 9. Lists

af Afrikaans
ak Akan
sq Albanian
am Amharic
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
sr Serbian
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

OK.

Now let's talk about lists.

So lists are data structures.

Now these data structures are changeable that we can re order them.

Put them in a list.

Right.

So they're just a group of elements.

And when you when you have this list everything inside that list is called an item.

And the best way to think of a list is to think that it lives in between brackets.

You're going to see other things later on that look like a list but it's not really a list because of

how it's defined and how we're going to define lists is because they live in brackets just like a string

might have quotes around it.

A list is going to have these brackets around it.

So let's make a new line and let's go ahead and just do something along the lines of lists and we could

say something like have the brackets like this.

OK.

So let's go ahead and make a list and then we can kind of go from there.

So let's define a list of your favorite movies.

Now you can put in whatever favorite movies you like in here and I'm going to put in something like

When Harry Met Sally

the hangover

The Perks of Being A Wallflower and this is getting kind of long so I'm actually going to move this

over a little bit for us and we'll say one more let's pick for movies.

We'll do the exorcist.

OK.

And now we have this this list again list.

Just live in brackets.

So we've got list item one item two item three and item for OK.

So let's go ahead and print these.

So if we were to print out something like movies and we said we wanted to print the first item out of

movies let's go ahead and try to print When Harry Met Sally.

So print the first item so put a bracket around it just like this or print it out and we'll see what

happens.

So let's say that.

And what's it going to return for us it's returning the hangover.

So item one is not item one as you see it.

So when we talk about items and we talk about numerical order here in Python item one is actually going

to be referred to as zero.

So make a note here for yourself that this will return.

The second item.

So if we wanted to return just When Harry Met Sally we would actually put in movies Zero like this and

we could say returns the first item in the list.

OK.

And we can say that and let's go ahead and give it a go.

Just to do proof of concept.

And there you go.

Remember that everything starts with zero and not one.

So when you're thinking about things let's think about them with zero as the beginning.

No.

So let's go ahead and do a few more different prints.

What's gonna happen when we print out something like this.

We'll say movies and we'll do one through three.

You have a hunch.

Let's go ahead and save it.

Print it out here and it will take the list here of starting at 1 and it'll end before 3.

So let's say we want to pull a couple of items out the first number that we're going to pull out is

going to be the one that we want to start with.

And the last number that we're going to pull out is going to be the number where we're going to stop.

So the X axis is three.

But if we wanted to actually pull down the axis we would have to pull down four here.

So if we want to try to grab more than one thing on the list we can absolutely do that.

But we have to know where to stop.

So now we incorporate the exorcist here.

Let's say we want to grab everything in a list and we wanted to grab everything after a certain point.

Right.

We could say something like movies one like this and then we should be able to grab every single thing

and that does pretty much the same thing here.

So if we had 30 items here it would grab all 30 items in this list if we wanted to grab three items

as we did before we would do one.

And then you just add three to that to four.

And it would stop.

So a little bit confusing.

This takes a little bit to wrap your mind around.

But the good thing here is that you take notes you can make notes however you feel comfortable with.

And these tricks should be useful for you.

So let's try another thing.

What if we said something like movies and we did this one in reverse.

We just did something like this when we did save Let's print it out.

What do you think's going to have an it's going to print When Harry Met Sally because it's going to

stop at the one we never get to one here again similar situation when we had this set of three we never

get to one we stop at one.

So we're gonna grab everything before one which is going to be just be When Harry Met Sally we could

set this to two and we would grab the hangover in this as well.

And just to prove concept here.

So that I'm not crazy.

You can see here the hangover gets added in because we get zero and we grab one.

You could also think of this if you don't confuse herself as grabbing two items out of the list but

make sure you don't confuse yourself because if this number were to be like two through four then it

would be something completely different.

Right.

So you need to make sure that you understand where from the list that you're actually grabbing where

Senate controls ease back.

So from here let's do two more tricks.

Actually we'll do one more trick and they'll move into some other items related to lists.

So if we say movies like this and we want to grab the very last item we can just put in a negative one

and so grab the absolute last item off the list.

That way.

If you have a list that's two thousand items long and you don't know where it ends.

You could just do negative one.

It's going to grab the last item for you and then you can see there it grab down the exorcist.

So cool little tricks you might not use these for a while and you probably won't see these come through

at least in anything we're going to really do in the course but they're still incredibly useful to know

about because they're they are included in the basics of Python.

So you're going to know the basics of Python and you will use these sometime in your lifetime.

It's useful to know this kind of stuff so we can also do some things with list as well.

We can print out the length of our lists so we can say length of movies something like this and get

that ago and you can see that there's four items in that list.

So we've seen length before with strings and it took every single character inside that string.

Here it's taking every single amount of item inside a list and pointing that out.

We can also append items to the list so we can say something like movies dot a pen.

And what if we really like Jaws and we add that into our favorite movies.

You can have too many favorite movies come on.

So let's go ahead and try printing that out and while we have to actually print it sorry movies out

of hand and then we say print movies now and it should print out with jobs added in.

Where do we think jobs is going to actually add itself into well if you said the end of the list you

are correct.

So when we append something we append it to the very end of the list.

What if we wanted to delete something from the list we could say something like this movie stop pop

and print movies.

Let's see what happens here

and now we got rid of Jaws.

So when we append We append to the end of the list if we want to delete the very last item in the list

we just use pop.

Now if we wanted to delete something like the first item or the second item we could do movies that

top and let's say 0 print movies.

So remove the very very first item in the list we should see you inherently disappear.

And there you go.

No longer is When Harry Met Sally and our list.

So this is a quick way that we can remove these items.

And on the fly if we need to to get rid of this.

So the high level overview here and the thing that you really need to take away is that list have brackets.

We're going to see something called dictionaries later.

We might see something called tuples later and they all look very very similar but here lists have brackets

inside those brackets are what we have that are called items.

OK.

And there are many different ways to return items.

The reason that I'm showing you these different ways is so that you can get familiar with the syntax

that we start our list or our items with zero and not one and that we can grab from these lists in different

ways.

OK.

And this will come back into play later with how we can utilize this same kind of syntax with other

items as well or other things in Python so we can also utilize you know printing out length or we can

do a append and add to the list or dot pop and there's a lot of different things that we can do here

to you know to append to these lists or remove from these lists et cetera.

So this is just the basics but hopefully what you take away from this is that lists have brackets and

you know the items there are items in the list and they start with zero.

Those are the key takeaways.

So in the next video we're going to briefly talk about tuples and then we're gonna move on into looping.

So let's go ahead and do that.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.