Coding basics · 14 of 20
Is it prime?
Return True if n is prime: bigger than 1 and divisible only by 1 and itself.
What you need
return inside a loop ends the function straight away. That's handy for "stop as soon as you find one".
for x in nums:
if x < 0:
return True # found one, done
return FalseExamples
Input n = 7
Output True
Input n = 9
Output False
9 = 3 × 3
Input n = 1
Output False
1 isn't prime.