1
00:00:00,870 --> 00:00:05,250
Now it's time to put what you've learned into practice and to actually learn

2
00:00:05,250 --> 00:00:10,250
through doing. So if you go to Repl.it where you are going to go to day 26.1 List

3
00:00:11,520 --> 00:00:16,050
Comprehension, and you're going to complete this challenge. So pause the video,

4
00:00:16,380 --> 00:00:17,100
head over there,

5
00:00:17,100 --> 00:00:20,370
read the instructions and see if you can complete the challenge.

6
00:00:20,760 --> 00:00:23,940
Once you're done, head back over here and I'll go through the solution with you.

7
00:00:26,400 --> 00:00:27,720
All right. So in this case,

8
00:00:27,780 --> 00:00:32,460
what we're trying to do is we're taking this list of numbers and we're basically

9
00:00:32,460 --> 00:00:36,750
going to write a single line of code here to change it

10
00:00:36,960 --> 00:00:41,670
so that we end up with a new list where each number is squared.

11
00:00:42,090 --> 00:00:45,570
A square number is basically just the number multiplied by itself.

12
00:00:45,990 --> 00:00:50,280
So for example, four squared is sixteen, two squared is four,

13
00:00:50,310 --> 00:00:54,930
three squared is nine. So let's go ahead and create our new list

14
00:00:55,290 --> 00:00:57,690
which it needs to be called squared numbers,

15
00:00:57,720 --> 00:00:59,310
because that's what we're going to print out.

16
00:00:59,370 --> 00:01:02,130
And that's what the automated testing is going to be looking for.

17
00:01:02,700 --> 00:01:07,620
This new list is going to be created using a list comprehension,

18
00:01:07,920 --> 00:01:09,990
so we're going to use our keyword method,

19
00:01:10,440 --> 00:01:14,400
new_item for item in list.

20
00:01:14,970 --> 00:01:19,020
And in this case, we actually don't need to do any conditional checking.

21
00:01:19,050 --> 00:01:21,750
We're taking every single one of these items,

22
00:01:22,050 --> 00:01:25,740
so this is the keyword that we need to fill in. The list,

23
00:01:25,740 --> 00:01:29,520
in this case, is our list of numbers. Each of the items,

24
00:01:29,520 --> 00:01:32,340
we can call it anything we want, but I'm going to call it num.

25
00:01:32,790 --> 00:01:35,820
And this new item is going to be num,

26
00:01:35,880 --> 00:01:39,750
so each of the items in that list, multiplied by itself.

27
00:01:40,110 --> 00:01:44,490
You can either do it like this which will get you the output that you need.

28
00:01:44,820 --> 00:01:48,930
Alternatively, you can use Python's built in exponents,

29
00:01:49,170 --> 00:01:52,350
which is just num**2.

30
00:01:52,680 --> 00:01:57,510
And this will square that number, which will give you exactly the same results.

31
00:01:58,080 --> 00:02:01,110
Now, you're ready to head over to the next lesson where we've got 

32
00:02:01,110 --> 00:02:03,120
another list comprehension exercise.

