I'm trying to make a code with one function that'll check for prime numbers in an array and it keeps saying that 33 is a prime number. What's wrong with my code:
def primes_nums(array):
prime = []
for i in array:
for x in range(2, (i-1)):
if i%x == 0:
print(i,' is not a prime number')
break
else:
prime.append(i)
break
return prime
pass
print(primes_nums([12, 33, 44, 89]))
The output comes out as:
12 is not a prime number
44 is not a prime number
[33, 89]