Answer to Question #305477 in Python for jkk

Question #305477

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


1
Expert's answer
2022-03-04T04:04:34-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS