-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathch-2.py
More file actions
37 lines (24 loc) · 682 Bytes
/
ch-2.py
File metadata and controls
37 lines (24 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python3
'''
Week 180:
https://theweeklychallenge.org/blog/perl-weekly-challenge-180
Task #2: Trim List
You are given list of numbers, @n and an integer $i.
Write a script to trim the given list where element is less than
or equal to the given integer.
'''
import unittest
def trimList(i, n):
trim_list = []
for j in n:
if j > i:
trim_list.append(j)
return trim_list
#
#
# Unit test class
class TestTrimList(unittest.TestCase):
def test_TrimList(self):
self.assertEqual(trimList(3, [1, 4, 2, 3, 5]), [4, 5])
self.assertEqual(trimList(4, [9, 0, 6, 2, 3, 8, 5]), [9, 6, 8, 5])
unittest.main()