+ 1
How can I write a code to find prime numbers in a given list?
4 odpowiedzi
+ 3
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n ** .5) + 1):
if n % i == 0:
return False
return True
num_list = [int(i) for i in input().split() if is_prime(int(i))]
print(num_list)
+ 2
+ 1
thank you
0
What language