1
00:00:01,530 --> 00:00:03,870
Hey, welcome to the experiments for today.

2
00:00:06,440 --> 00:00:14,000
Earlier today, we needed to remove the brake lines from each to do item, and for that we tried to

3
00:00:14,000 --> 00:00:17,870
different ways with first tried the list comprehension.

4
00:00:20,440 --> 00:00:23,110
Which looked something like this.

5
00:00:23,470 --> 00:00:27,550
So we reassigned the new client list to a.

6
00:00:29,100 --> 00:00:30,300
New variable.

7
00:00:31,600 --> 00:00:37,840
But then we found out that since we have this for loop, then we could simply apply the strip method

8
00:00:37,840 --> 00:00:42,730
here instead of iterating over the list in a list comprehension.

9
00:00:44,770 --> 00:00:49,360
So then what I did is I removed this line from the code.

10
00:00:49,390 --> 00:00:49,780
Ah.

11
00:00:49,780 --> 00:00:58,150
But a better way would be to just comment this line.

12
00:01:00,150 --> 00:01:04,349
The way you comment a line is by using.

13
00:01:06,830 --> 00:01:07,730
The hash.

14
00:01:08,400 --> 00:01:09,240
Symbol.

15
00:01:09,990 --> 00:01:14,490
So you just add that symbol in front of the line, you want to comment.

16
00:01:14,490 --> 00:01:16,440
So what is commenting anyway?

17
00:01:17,010 --> 00:01:22,320
Well, commenting means this line will not be executed by the interpreter now.

18
00:01:25,150 --> 00:01:26,890
So it is in the code.

19
00:01:26,920 --> 00:01:32,200
It's just for us programmers to see it, but the interpreter will not use it.

20
00:01:33,240 --> 00:01:41,850
Now we get this on the line here because it is recommended to have a space between the symbol and the

21
00:01:41,850 --> 00:01:42,960
command line.

22
00:01:44,160 --> 00:01:45,420
It is not a requirement.

23
00:01:45,420 --> 00:01:46,800
It is a recommendation.

24
00:01:49,800 --> 00:01:58,340
So another illustration, if we had this print function here on top, how high and we run the codes,

25
00:01:58,350 --> 00:02:00,330
of course we would see how high.

26
00:02:00,990 --> 00:02:10,440
But if I add the hash symbol in front of print and and I run the code now, I will not print it out.

27
00:02:13,190 --> 00:02:22,030
So comments are useful to have when you have some codes that maybe you want to execute in the future,

28
00:02:22,040 --> 00:02:30,020
maybe you're not sure if you really want to delete it, so just keep it for reference there.

29
00:02:31,460 --> 00:02:35,090
So the comment feature would be useful for that.

30
00:02:36,110 --> 00:02:43,670
So that's one use of the comments to just comment code out so it is not executed.

31
00:02:43,970 --> 00:02:49,340
The other usefulness is to describe your code.

32
00:02:50,420 --> 00:02:51,590
For example.

33
00:02:52,840 --> 00:02:59,920
Let's say that when you come later on in your code and you don't remember what you're doing in these

34
00:02:59,920 --> 00:03:00,910
two lines.

35
00:03:02,200 --> 00:03:08,200
So it's a good idea to actually when you're programming, it's a good idea to actually write a comment

36
00:03:08,200 --> 00:03:11,650
here that describes these two lines.

37
00:03:11,650 --> 00:03:18,730
For example, get user input and remove or and strip.

38
00:03:20,570 --> 00:03:22,670
Space characters.

39
00:03:24,060 --> 00:03:24,870
From it.

40
00:03:27,030 --> 00:03:33,180
So by looking at this, it gives you some information about what these two lines are doing.

41
00:03:36,040 --> 00:03:40,270
Similarly, you could add a comment above this line.

42
00:03:40,270 --> 00:03:46,720
So you press enter here to create a break line, the hash symbol, and then you say.

43
00:03:47,900 --> 00:03:52,520
Check if user action is.

44
00:03:53,800 --> 00:03:54,670
And.

45
00:03:56,270 --> 00:04:02,260
So that comment tells you that this case ad is checking for the user action.

46
00:04:02,270 --> 00:04:06,180
However, you shouldn't abuse comments.

47
00:04:06,200 --> 00:04:14,630
So I do think that in this case, this comment is unnecessary because as a programmer, you know, that

48
00:04:14,630 --> 00:04:19,339
case ad checks the string against that variable.

49
00:04:19,339 --> 00:04:27,770
So it doesn't really give any much extra information to just say what case ad does.

50
00:04:27,980 --> 00:04:34,700
So you only need you only want to use comments when you really think it's necessary that I code the

51
00:04:34,700 --> 00:04:40,490
line should have more extra information to tell to the programmer.

52
00:04:41,410 --> 00:04:45,470
And that is also why variable naming is important.

53
00:04:45,470 --> 00:04:51,410
So you should use meaningful names for variables so that you don't have to use comments.

54
00:04:52,410 --> 00:05:01,770
For example, by saying here to dos, you know, that this is a list of to two items.

55
00:05:02,640 --> 00:05:09,750
But if you just said Delta, then it would be a bit ambiguous what this would actually mean.

56
00:05:10,020 --> 00:05:13,830
So be specific and descriptive with variable names.

57
00:05:15,120 --> 00:05:24,390
So use comments whenever you think some code does really need some description and that's what you normally

58
00:05:24,390 --> 00:05:24,630
do.

59
00:05:24,630 --> 00:05:28,590
So write the line above a block of code.

60
00:05:29,460 --> 00:05:31,710
For example, here would be another example.

61
00:05:35,440 --> 00:05:36,950
Right to do.

62
00:05:37,630 --> 00:05:40,240
In the file.

63
00:05:41,980 --> 00:05:46,840
But again, this wouldn't be necessary because we know what the open function does.

64
00:05:49,250 --> 00:05:53,750
But if you wanted to comment that blog, you just write the comments on top of it.

65
00:05:54,870 --> 00:05:58,070
So that's about code experiments for today.

66
00:05:58,080 --> 00:06:02,190
We were focused on comments and let's keep going.

