Write a python function Read_Prime(fname, list) which takes a list of numbers as an input, use this number to write them in a file "primes.txt" . The function then read the file and return a list containing only prime numbers as shown in the example. Also, write the exception handling code to show the proper message
from sumpy import *
with open('primes.txt') as f:
primes = []
for n in [[int(x) for x in line.split()] for line in f]:
if isprime(n):
primes.append(n)
print(primes)
Comments
Leave a comment