File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
course_contents/1_intro/notes Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## IS
2
+ - Return True if the operands have the same identity
3
+
4
+ Example:
5
+ ```
6
+ users = ['James', 'Charlie', 'Ana']
7
+ print(id(users)) # 2425142160952
8
+
9
+ users_copy = users
10
+ print(id(users_copy)) # 2425142160952
11
+
12
+ print(users_copy is users) # True
13
+
14
+ users_copy = users[:]
15
+ print(id(users_copy)) # 2425142558551
16
+
17
+ print(users_copy is users) # False
18
+ ```
19
+
20
+ ## IS NOT
21
+ - Returns True if the operands don't have the same identity
22
+
23
+ Example:
24
+ ```
25
+ users = ['James', 'Charlie', 'Ana']
26
+ print(id(users)) # 2425142160952
27
+
28
+ users_copy = users
29
+ print(id(users_copy)) # 2425142160952
30
+
31
+ print(users_copy is users) # False
32
+
33
+ users_copy = users[:]
34
+ print(id(users_copy)) # 2425142558551
35
+
36
+ print(users_copy is users) # True
37
+ ```
You can’t perform that action at this time.
0 commit comments