Program for copying prime numbers from a list to a new list
def primechk(n):
t = 0 # Used for storing factors
for i in range(1,n+1):
if n % i == 0:
t+=1
return True if t==2 else False
x1= [90,50,79,88,39,61,89,111,139]
x2=[]
for i in x1:
y = primechk(i)
if y == True:
x2.append(i)
else:
pass
print(x1)
print(x2)
Comments
Post a Comment
😊Your comments are valuable for us!