I need a code on Python that receives as the input a list of numbers, and from that the program returns True
if there are any prime numbers on the list or False
if otherwise.
As a beginner I am only allowed to use basic functions (e.g if..else
, while
, range
, for
). I have tried writing this code so far, but it doesn't seem to be working:
## Function to check if a number is prime
def isPrime (x):
if (x%2 !=0 and x%3 !=0 and x%5 !=0 and x%7 !=0):
return True
elif (x==2 or x==3 or x==5 or x==7):
return True
else:
return False
## Verify if the list contains prime numbers
def primelist(*x):
for i in x:
if isPrime(i)==True:
return True
if isPrime(i)==False:
return False
primelist = (3,6,8,9,12)
The expected outcome would be True
once 3 is a prime, but I am getting no response. What am I doing wrong?