1
1

00:00:00,400  -->  00:00:02,100
<v ->Hi, guys, and welcome back.</v>
2

2

00:00:02,100  -->  00:00:03,320
In this video, we're going to learn
3

3

00:00:03,320  -->  00:00:05,980
about the in keyword in Python.
4

4

00:00:05,980  -->  00:00:07,920
The in keyword is something we can use
5

5

00:00:07,920  -->  00:00:09,750
to check for membership,
6

6

00:00:09,750  -->  00:00:12,580
whether one thing is inside a list
7

7

00:00:12,580  -->  00:00:14,123
or a tuple or a set.
8

8

00:00:14,960  -->  00:00:16,370
Let's get started.
9

9

00:00:16,370  -->  00:00:17,930
I'll have a list of friends,
10

10

00:00:17,930  -->  00:00:22,440
which contains Rolf, Bob, and Jen.
11

11

00:00:22,440  -->  00:00:24,100
And then we can very easily print
12

12

00:00:24,100  -->  00:00:27,423
whether Jen is in friends.
13

13

00:00:28,310  -->  00:00:31,300
And this is going to check whether the string Jen
14

14

00:00:31,300  -->  00:00:35,180
is one of the members in this list.
15

15

00:00:35,180  -->  00:00:37,690
So if we save that and run it,
16

16

00:00:37,690  -->  00:00:39,623
you'll see that we get back true.
17

17

00:00:41,950  -->  00:00:44,160
Now let's say that we have a set
18

18

00:00:44,160  -->  00:00:46,470
of the movies we've recently watched.
19

19

00:00:46,470  -->  00:00:47,650
I'm using a set here
20

20

00:00:47,650  -->  00:00:51,800
because movies are unique, so you can't have duplicates
21

21

00:00:51,800  -->  00:00:55,470
and having a set actually helps you prevent duplication.
22

22

00:00:55,470  -->  00:00:57,270
In addition, the movies that we've watched
23

23

00:00:57,270  -->  00:00:59,890
in this case don't have any specific order.
24

24

00:00:59,890  -->  00:01:01,650
So we don't care about the order,
25

25

00:01:01,650  -->  00:01:04,030
and therefore a set is a perfect structure
26

26

00:01:04,030  -->  00:01:05,503
to put these movies into.
27

27

00:01:06,360  -->  00:01:08,550
Then we are going to ask the user
28

28

00:01:08,550  -->  00:01:10,493
for a movie they've watched recently.
29

29

00:01:15,420  -->  00:01:16,900
And finally, we're going to print
30

30

00:01:16,900  -->  00:01:20,633
whether that movie is in our movies watched.
31

31

00:01:22,200  -->  00:01:23,310
If we run this,
32

32

00:01:23,310  -->  00:01:27,430
then you'll see that if we type The Matrix, you get true,
33

33

00:01:27,430  -->  00:01:29,920
but if you type Monty Python,
34

34

00:01:29,920  -->  00:01:31,593
then you'll get false.
35

35

00:01:33,010  -->  00:01:35,810
The in keyword works in sequences
36

36

00:01:35,810  -->  00:01:38,050
like lists, tuples, sets.
37

37

00:01:38,050  -->  00:01:39,780
It also works in strings, actually,
38

38

00:01:39,780  -->  00:01:42,200
so you can check whether a string
39

39

00:01:42,200  -->  00:01:45,350
is inside another string, such as a substring.
40

40

00:01:45,350  -->  00:01:50,290
For example, R-I-X would be in The Matrix.
41

41

00:01:50,290  -->  00:01:53,060
So you can do checks like that, as well, if you want.
42

42

00:01:53,060  -->  00:01:54,220
Let's move on to the next video
43

43

00:01:54,220  -->  00:01:56,440
where we're gonna learn how to use if statements
44

44

00:01:56,440  -->  00:01:58,030
with this syntax here
45

45

00:01:58,030  -->  00:02:00,610
so that we can create even more powerful programmes.
46

46

00:02:00,610  -->  00:02:01,560
I'll see you there.
