0
Answer generator to practice .
Please, somebody should help me with the generator practice problem. THis code below is my solution but I'm still stuck with answer to last test question. #your code goes here Primes = [n for n in range(a, b+1) if isPrime(n)] return Primes f = int(input("")) t = int(input("")) print(list(primeGenerator(f, t)))
2 Antworten
+ 5
The inputs statements should be at the beginning of the code otherwise your code have not something to calculate any results.
+ 2
generators use
yield
instead of return
and you don't yield the entire list. yield n one by one....
for n in range(a,b):
if isPrime(n):
yield n
hint: the test fails if you use b+1. The designer of the test did not specifically said that the range is inclusive, so we should not make the assumption that it is.