diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-03 21:38:53 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-03 21:38:53 +0100 |
| commit | 0ea24ad3f2e62e9531e778ee31b582d73efe4b77 (patch) | |
| tree | 72f6f4d626a3cdbea98d71ad60d9c08a8b83b3e7 /challenge-180/mohammad-anwar/python/ch-2.py | |
| parent | 198cd4bdf0fc36df387cf2a636fadbfb74f9a169 (diff) | |
| download | perlweeklychallenge-club-0ea24ad3f2e62e9531e778ee31b582d73efe4b77.tar.gz perlweeklychallenge-club-0ea24ad3f2e62e9531e778ee31b582d73efe4b77.tar.bz2 perlweeklychallenge-club-0ea24ad3f2e62e9531e778ee31b582d73efe4b77.zip | |
- Added solutions to week 180.
Diffstat (limited to 'challenge-180/mohammad-anwar/python/ch-2.py')
| -rw-r--r-- | challenge-180/mohammad-anwar/python/ch-2.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-180/mohammad-anwar/python/ch-2.py b/challenge-180/mohammad-anwar/python/ch-2.py new file mode 100644 index 0000000000..127805093f --- /dev/null +++ b/challenge-180/mohammad-anwar/python/ch-2.py @@ -0,0 +1,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() |
