1
00:00:02,090 --> 00:00:03,200
Welcome back.

2
00:00:03,200 --> 00:00:07,460
So in this lesson we should take a look at lists one way to do this.

3
00:00:07,460 --> 00:00:16,070
I'm going to create a new project or a new script by coming by her have new and then I'm going to press

4
00:00:16,070 --> 00:00:21,710
control and as other same time and call this number two and to underscore list that's going to be the

5
00:00:21,710 --> 00:00:22,680
name of this one.

6
00:00:22,820 --> 00:00:27,560
Once that is done we can close this old one and I'll expand a bit.

7
00:00:28,550 --> 00:00:35,360
So in Python lists are very similar to the arrays we are used to in things like C language Java and

8
00:00:36,500 --> 00:00:38,120
C++.

9
00:00:38,300 --> 00:00:41,150
We can append elements to list we can.

10
00:00:41,180 --> 00:00:45,170
It's Rachel about them and do all sorts of things with list.

11
00:00:45,200 --> 00:00:45,980
Let's get started.

12
00:00:45,980 --> 00:00:49,750
So to declare lists let's say I have a list that I call my list.

13
00:00:50,030 --> 00:00:57,080
I can simply see my list of course this this is how we declare a list so we can see in my list is this

14
00:00:57,540 --> 00:01:04,490
and to add an element to runtime lessee I have this list it's existent some way in code line number

15
00:01:04,490 --> 00:01:06,700
one and line 200.

16
00:01:06,770 --> 00:01:08,850
I want to add an element to this list.

17
00:01:08,960 --> 00:01:11,720
I can just see my list dot append

18
00:01:14,330 --> 00:01:24,140
and then I can add a number that say I'd in 56 to it and let's see our press control s and actually

19
00:01:24,140 --> 00:01:31,460
let's print so that we don't print all by that I can see print and to print to access to the element.

20
00:01:31,490 --> 00:01:34,790
So you can see this is the first element added to the list.

21
00:01:34,790 --> 00:01:44,570
Therefore this is going to be at index number zero of the list so I can just say print my list and then

22
00:01:44,890 --> 00:01:47,050
over here I pass index number zero.

23
00:01:47,290 --> 00:01:48,860
So press controls to save.

24
00:01:48,860 --> 00:01:50,970
Click Run Run module.

25
00:01:51,350 --> 00:01:54,410
And as you can see it's returned to 56.

26
00:01:54,410 --> 00:01:59,430
So indeed with appended this and we can append as many elements as we want.

27
00:01:59,450 --> 00:02:12,050
I can see my list dot append three or four and then I can you can continue by seeing my list append

28
00:02:13,400 --> 00:02:17,630
then 67 Exeter.

29
00:02:17,660 --> 00:02:18,400
Right.

30
00:02:18,440 --> 00:02:22,040
So then we can change and I can come over here and see.

31
00:02:22,070 --> 00:02:29,570
Show me what is at index number to click over here to run click OK to save and run and then indeed index

32
00:02:29,570 --> 00:02:33,620
number two sixty seven course this index 0 Number 1.

33
00:02:33,620 --> 00:02:41,450
Number two in the same way we could iterate over the element in the list and we can come down here see

34
00:02:41,570 --> 00:02:50,000
for a for loop is for our simple n in python you a fourth and then you create an iterator let's give

35
00:02:50,010 --> 00:02:56,870
our it's written name x x is going to iterate what do we want to iterate through we're going to iterate

36
00:02:56,870 --> 00:03:01,400
through a list called my list as we declared up there.

37
00:03:01,580 --> 00:03:10,450
So as simple as 4 x in my list and then call on no one can come here and say print x.

38
00:03:10,940 --> 00:03:17,600
So what's going to happen is just by using my list python will get a length of this list and it's going

39
00:03:17,600 --> 00:03:24,830
to know that the list has three element to it X is going to start with x 0 x 1 and then x 2 therefore

40
00:03:24,830 --> 00:03:30,130
it's going to print was that you know x 0 X1 and then x 2.

41
00:03:30,230 --> 00:03:30,710
Exactly.

42
00:03:30,710 --> 00:03:33,520
So let's see what this would give us.

43
00:03:33,560 --> 00:03:46,360
Come over here you can see it's given us given us let's see it's given us fifty six four and then six

44
00:03:46,360 --> 00:03:53,120
to seven less less clean this less comment this out with comment with the no sign or the harsh sign

45
00:03:53,120 --> 00:03:59,000
in Python so you can just comment this out because this is confusing our resort so once that is done

46
00:03:59,000 --> 00:04:06,410
we can run and see and indeed with iterate through the list very simply just by using X and we didn't

47
00:04:06,440 --> 00:04:13,490
even need to see for X and we need to see things like the length of the list just by using the list

48
00:04:13,540 --> 00:04:13,850
name.

49
00:04:13,880 --> 00:04:20,570
Python gets that length and its way through and just by using X we didn't even have to say print.

50
00:04:20,640 --> 00:04:27,920
You know my list index X in the standard to see what we may have to do would be to say print my list

51
00:04:29,030 --> 00:04:35,280
like this and then pass expert over here index X in Python.

52
00:04:35,330 --> 00:04:42,470
We can simply say for X this is the simple way to iterate through a list for x in my list is going to

53
00:04:42,530 --> 00:04:49,850
automatically get you use x to represent each index and then print out the content.

54
00:04:51,020 --> 00:04:55,900
So this is a like this index number zero number one.

55
00:04:55,900 --> 00:04:57,610
Number two a simple cluster.

56
00:04:58,990 --> 00:05:00,280
So this all there is for list.

57
00:05:00,280 --> 00:05:04,820
This is the basics we're going to be using these things and all you need to know about this this.

58
00:05:04,910 --> 00:05:05,810
Showing you.

59
00:05:06,100 --> 00:05:11,710
So this or there is for this very short lesson if you have any questions as usual just send me a message

60
00:05:11,710 --> 00:05:16,540
or leave it in the questions area and I shall see you in the next lesson.

61
00:05:16,540 --> 00:05:17,340
Have a good day.
