1 00:00:00,000 --> 00:00:09,630 Now, we said that 2 00:00:09,630 --> 00:00:12,150 we are going to cover three kinds of sequences. 3 00:00:12,150 --> 00:00:14,850 So, we've already done strings and lists, 4 00:00:14,850 --> 00:00:22,060 but the third kind of sequence that I'm going to cover rather quickly are tuples. 5 00:00:24,140 --> 00:00:27,480 The reason that I'm going to cover tuples relatively 6 00:00:27,480 --> 00:00:30,950 quickly are that tuples are just like lists, 7 00:00:30,950 --> 00:00:33,110 except the difference between a tuple and 8 00:00:33,110 --> 00:00:36,760 a list is that tuples are what are called immutable. 9 00:00:36,760 --> 00:00:38,860 Meaning that after a tuple is created, 10 00:00:38,860 --> 00:00:40,355 it can't be changed. 11 00:00:40,355 --> 00:00:43,520 We're going to talk more about mutability later on, 12 00:00:43,520 --> 00:00:47,135 but for now I'm just going to cover how to create a tuple. 13 00:00:47,135 --> 00:00:51,170 So here, I create a list with three items, 14 00:00:51,170 --> 00:00:54,950 and to create a three-item tuple I would do something very similar. 15 00:00:54,950 --> 00:00:58,550 So, I would say myTuple equals, 16 00:00:58,550 --> 00:01:01,880 and basically I would take almost the same syntax, 17 00:01:01,880 --> 00:01:06,795 except I would replace the square brackets with parentheses. 18 00:01:06,795 --> 00:01:09,630 So, the first item is the string one, 19 00:01:09,630 --> 00:01:11,925 the second item is the integer two, 20 00:01:11,925 --> 00:01:15,095 the third item is the string three, 21 00:01:15,095 --> 00:01:20,235 and I have to close parentheses to say that this is the end of the tuple. 22 00:01:20,235 --> 00:01:26,665 Now, if I print out the type of my tuple run it, 23 00:01:26,665 --> 00:01:34,340 then I'll see that list or myList is a list and myTuple is a tuple. 24 00:01:36,620 --> 00:01:39,890 So, for the most part when creating tuples, 25 00:01:39,890 --> 00:01:43,330 then you can just use the same syntax that you use for lists, 26 00:01:43,330 --> 00:01:47,710 except replace these square brackets with parentheses. 27 00:01:47,710 --> 00:01:50,380 There are just a few exceptions where creating 28 00:01:50,380 --> 00:01:53,425 tuples is slightly different from creating lists. 29 00:01:53,425 --> 00:02:00,580 So, let's suppose that I have a list with 100 as its only item, 30 00:02:00,580 --> 00:02:03,970 and I want to create a tuple with one item as well, 31 00:02:03,970 --> 00:02:06,415 so I want that item to be 100. 32 00:02:06,415 --> 00:02:09,100 When Python sees this expression, 33 00:02:09,100 --> 00:02:12,095 it actually thinks that this is an integer. 34 00:02:12,095 --> 00:02:13,820 So, when I run my code, 35 00:02:13,820 --> 00:02:16,240 and then I can see that my tuple or 36 00:02:16,240 --> 00:02:20,650 this expression actually created an integer whose value is 100, 37 00:02:20,650 --> 00:02:22,960 and that's because Python was a little bit 38 00:02:22,960 --> 00:02:25,510 confused here because it thought that I was putting 39 00:02:25,510 --> 00:02:30,430 100 in parentheses to do something like change the order of operations. 40 00:02:30,430 --> 00:02:33,100 So, it thought that I meant to create an integer. 41 00:02:33,100 --> 00:02:36,980 In order to specify that I want to create the tuple 100, 42 00:02:36,980 --> 00:02:39,395 I just have to add an extra comma. 43 00:02:39,395 --> 00:02:41,120 And with that extra comma, 44 00:02:41,120 --> 00:02:42,740 if I rerun my code, 45 00:02:42,740 --> 00:02:46,345 then I'll see that my tuple is a tuple again. 46 00:02:46,345 --> 00:02:49,790 If I want to create a tuple with zero items, 47 00:02:49,790 --> 00:02:52,295 just like I can create a list with zero items, 48 00:02:52,295 --> 00:02:53,735 then I can just say, 49 00:02:53,735 --> 00:02:56,435 open and close parentheses with nothing in it, 50 00:02:56,435 --> 00:03:01,710 and you'll see that my tuple is still a tuple. Until next time.