Now, we said that
we are going to cover three kinds of sequences.
So, we've already done strings and lists,
but the third kind of sequence that I'm going to cover rather quickly are tuples.
The reason that I'm going to cover tuples relatively
quickly are that tuples are just like lists,
except the difference between a tuple and
a list is that tuples are what are called immutable.
Meaning that after a tuple is created,
it can't be changed.
We're going to talk more about mutability later on,
but for now I'm just going to cover how to create a tuple.
So here, I create a list with three items,
and to create a three-item tuple I would do something very similar.
So, I would say myTuple equals,
and basically I would take almost the same syntax,
except I would replace the square brackets with parentheses.
So, the first item is the string one,
the second item is the integer two,
the third item is the string three,
and I have to close parentheses to say that this is the end of the tuple.
Now, if I print out the type of my tuple run it,
then I'll see that list or myList is a list and myTuple is a tuple.
So, for the most part when creating tuples,
then you can just use the same syntax that you use for lists,
except replace these square brackets with parentheses.
There are just a few exceptions where creating
tuples is slightly different from creating lists.
So, let's suppose that I have a list with 100 as its only item,
and I want to create a tuple with one item as well,
so I want that item to be 100.
When Python sees this expression,
it actually thinks that this is an integer.
So, when I run my code,
and then I can see that my tuple or
this expression actually created an integer whose value is 100,
and that's because Python was a little bit
confused here because it thought that I was putting
100 in parentheses to do something like change the order of operations.
So, it thought that I meant to create an integer.
In order to specify that I want to create the tuple 100,
I just have to add an extra comma.
And with that extra comma,
if I rerun my code,
then I'll see that my tuple is a tuple again.
If I want to create a tuple with zero items,
just like I can create a list with zero items,
then I can just say,
open and close parentheses with nothing in it,
and you'll see that my tuple is still a tuple. Until next time.