Print True if n is prime?
is_prime = True for i in range(2,n): if n%i == 0: #blank# print(is_prime) Can you fill in the #blank# line so the code will only print True if n is prime?
If you want to print False, whenever n is not a prime then do following- is_prime = False break Here "break" statement will terminate the loop and print statement will execute, because there is no need for checking higher values of i anymore.
not any([n%i==0 for i in range(2,n)])
is_prime = True for i in range(2,n): if n%i == 0: if n > 1: print("False") break else: print(is_prime)
is_prime = False
Error in Program
BMI calculator code project