I am trying to print all primes from 1 to 100 using a boolean function.
Below my code works.
for n in range(1,101): status = True if n < 2: status = False else: for i in range(2,n): if n % i == 0: status = False if status: print(n, '', sep=',', end='')
But when I put the code in the function and launch module, nothing is printed in the shell. What have I done wrong?
is_prime(): for n in range(1,101): status = True if n < 2: status = False else: for i in range(2,n): if n % i == 0: status = False return status if is_prime(): print(n, '', sep=',', end='')
Below is the result of the program. How to prevent the printing of the last comma?
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,