def judge(x): for i in range(2, x): if x % i == 0: return False return True num = [1, 3, 4, 5, 6, 7, 8, 9] for j in num: print(j) if judge(j): num.remove(j)