Instructor: I wanna teach you one last thing
when it comes to lists,
and it's called list unpacking.
And it's a really, really nice feature.
I really like it.
With list unpacking, we can do something like this.
Let's say I have a list
that is very simple, 1, 2, and 3.
And I wanna assign a variable to this list.
Let's call it basket = 1, 2, 3.
But what if I wanted to assign a variable to each item?
Well, I can actually do something like this: a, b, c.
So that, when I print a,
and then let's print b,
and then print c,
and I click run,
I get 1, 2, 3.
And this is something that we've seen
when we talked about variables.
Where, even if it wasn't a list,
as long as we gave it by comma separated by comma,
different values,
we're able to print 1, 2, 3.
But this is where list unpacking gets really, really useful.
We can actually, let's say, extend our list to include
all the way till 9.
What if we wanted to unpack 1, 2, and 3
but keep everything else still in a list?
Could we still do that?
Well, with list unpacking we can.
All we need to do is say comma and then add a star
and give it a variable name whatever we like.
Let's say, other.
So now if I print other and I click run,
look at that.
I'm able to unpack my list however way I want.
What if I add a comma here and add d?
Well, if I run this, I get a list all the way until 8.
But now D is, well actually,
the very last item.
So that's very, very neat.
Maybe the use case right now is not absolutely clear to you,
but this is something that might help you another tool
in your toolbox to unpack a list
and change a list in different ways.
We'll explore this more later on in this course,
but for now, list unpacking,
when you hear that word now you know what it means.
I'll see you in the next one.
Bye-bye.