I want a list of n
numbers and check each item for primality and log whether the given number is prime or not. Unfortunately my below shown code is working incorrectly and I need help finding out why is it happening.
My code snippet:
l1 = []
num = int(input("Enter a range of numbers :: "))
for i in range(2, num + 1):
l1.append(i)
for i in range(0, num - 1):
for j in range(2, num):
if l1[i] % j == 0:
print(f'{l1[i]} is not a prime ')
break
else:
print(f'{l1[i]} is a prime number')