summary refs log tree commit diff stats
path: root/python/code/2/2.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/code/2/2.py')
-rw-r--r--python/code/2/2.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/code/2/2.py b/python/code/2/2.py
new file mode 100644
index 0000000..bb3e9d2
--- /dev/null
+++ b/python/code/2/2.py
@@ -0,0 +1,12 @@
+def is_prime(n):
+    if n < 2: return False
+    for i in range(2, n):
+        if n % i == 0: return False
+    return True
+
+def filter_prime(numbers):
+    return [number for number in numbers if is_prime(number)]
+
+numbers = [int(n) for n in input('Enter a list of numbers: ').split()]
+primes = [number for number in numbers if is_prime(number)]
+print('List of primes:', primes)