1
00:00:00,630 --> 00:00:03,290
Hello and welcome to this video.

2
00:00:03,330 --> 00:00:10,930
In this video we are going to be creating a list to create a list you just need to give the list in

3
00:00:10,930 --> 00:00:16,960
name you use the quotes too and then you assign the values in the list.

4
00:00:17,160 --> 00:00:21,480
So you the left square bracket opens up the list.

5
00:00:21,540 --> 00:00:26,940
Then you add the values in the list you separate it value with a comma.

6
00:00:27,210 --> 00:00:34,350
If it's a text or a string you need to enclose it in quotes like I have done in the illustration.

7
00:00:34,350 --> 00:00:41,890
And then you use the right square bracket to close the list so let's create a list.

8
00:00:42,240 --> 00:00:50,220
So to create the list I'm going to be using the text editor code item and I've created a new python

9
00:00:50,220 --> 00:00:57,750
file which is this file here on my desktop and I've called it my list so you can create a file a python

10
00:00:57,750 --> 00:01:02,610
file and then just save it anywhere your desktop might be easier.

11
00:01:02,620 --> 00:01:05,370
Like I have done and then this is the file.

12
00:01:05,370 --> 00:01:10,710
So this is where I'm going to be creating my list to create a list.

13
00:01:10,710 --> 00:01:11,910
You start with a name.

14
00:01:11,910 --> 00:01:21,080
Always give your list a descriptive name to reflect the type of elements that the list is storing.

15
00:01:21,090 --> 00:01:30,810
So I'm creating a list called animals and I'm going to set that to the different values.

16
00:01:30,840 --> 00:01:33,480
So I can just say the first value in there.

17
00:01:33,510 --> 00:01:36,360
I can see a bear.

18
00:01:36,540 --> 00:01:46,540
A comma to separate the values add another value I'll say maybe a tiger do a comma add another one.

19
00:01:46,560 --> 00:01:53,690
Let's say a lion and so long you cannot as many items as you want in the list.

20
00:01:53,860 --> 00:01:55,540
I'm going to.

21
00:01:55,700 --> 00:02:00,910
Let's see how it panned up let's add one more.

22
00:02:00,910 --> 00:02:07,220
And the comma and I'll make this one an elephant.

23
00:02:07,250 --> 00:02:12,170
So these are now elements in my list.

24
00:02:12,170 --> 00:02:16,210
So to save the file just to control is on a Windows.

25
00:02:16,220 --> 00:02:20,020
If you're on a Mac you do command s.

26
00:02:20,190 --> 00:02:27,810
You can use what is called a for loop if you want to loop through the elements in the list and print

27
00:02:27,810 --> 00:02:28,510
them out.

28
00:02:28,560 --> 00:02:36,060
You can loop through them and the way you could do that you just to four and you say four X lists represent

29
00:02:36,120 --> 00:02:49,850
the name of the list as X so we can say for x in animals and they had a colon and then you use the print

30
00:02:50,120 --> 00:02:54,840
function or print statement impasse in the value of x.

31
00:02:54,890 --> 00:02:57,850
So I chose to control s to save.

32
00:02:58,190 --> 00:03:06,260
And when I open up my command prompt which is this and to access this file here which I've said I'll

33
00:03:06,260 --> 00:03:15,800
just call it by its name which is my list dot P Y and our press pointer I can see here is listed all

34
00:03:15,800 --> 00:03:18,500
the elements of the list.

35
00:03:18,500 --> 00:03:23,750
So I'm just going to clear my console by typing in C or less if you're on a Mac you can just typing

36
00:03:23,760 --> 00:03:29,460
color and that will play the console or terminal.

37
00:03:29,840 --> 00:03:38,120
You can also use the print function on its own just to print the list so I can type in print and inside

38
00:03:38,120 --> 00:03:40,300
the parentheses for the print function.

39
00:03:40,310 --> 00:03:48,250
I just pass in the name of the list and what that would do it would just print exactly as it is.

40
00:03:48,260 --> 00:03:57,350
So I do control as to save if I open up my terminal type in the name which is my list dot P why I'm

41
00:03:57,350 --> 00:04:03,320
pressed into when you execute code the code will execute in the order you have written it.

42
00:04:03,320 --> 00:04:09,770
So it's printing out each item first using this block of code and then it goes onto this block of code

43
00:04:09,800 --> 00:04:13,170
and just prints the which is this bug block here.

44
00:04:13,280 --> 00:04:17,480
It prints the entire list just the way it was created.

45
00:04:18,110 --> 00:04:23,020
So that's basically how to create a list in Python.

46
00:04:23,030 --> 00:04:24,950
Thanks for watching and bye for now.
