You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, set the variable `italy` to be equal to the third to last element from `countries`.
66
50
>**Note:** If you see an **error** stating that `countries` is undefined, it means you must press shift+enter in the second gray box where `countries` variable is assigned.
67
51
@@ -78,14 +62,6 @@ italy
78
62
italy # 'Italy'
79
63
```
80
64
81
-
82
-
```python
83
-
%%unittest_testcase
84
-
85
-
deftest_italy(self):
86
-
self.assertEqual(italy, 'Italy')
87
-
```
88
-
89
65
Now access the fourth element and set it equal to the variable `mexico`.
90
66
91
67
@@ -94,14 +70,6 @@ mexico = None
94
70
mexico
95
71
```
96
72
97
-
98
-
```python
99
-
%%unittest_testcase
100
-
101
-
deftest_mexico(self):
102
-
self.assertEqual(mexico, 'Mexico')
103
-
```
104
-
105
73
Notice that the second through fifth elements are all in a row and all in the Western Hemisphere. Assign that subset of elements to a variable called `kindof_neighbors`.
Now the number of repeat countries should be the number of countries minus the number of unique countries. So use the `len` function on both `unique_countries` and `countries` to calculate this and assign the result to the variable `num_of_repeats`.
252
180
253
181
@@ -256,14 +184,6 @@ num_of_repeats = None
256
184
num_of_repeats # 3
257
185
```
258
186
259
-
260
-
```python
261
-
%%unittest_testcase
262
-
263
-
deftest_num_of_repeats(self):
264
-
self.assertEqual(num_of_repeats, 3)
265
-
```
266
-
267
187
### Summary
268
188
269
189
In this lesson, we had some practice with working with lists in Python. We saw how to add and remove elements from a list, as well as select specific elements. Finally, we saw how to use a different data structure to calculate the number unique elements in the list.
0 commit comments