Answer generator to practice . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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)))

4th Feb 2024, 7:05 AM
ADOLPHUS Okeke
ADOLPHUS Okeke - avatar
2 Answers
+ 5
The inputs statements should be at the beginning of the code otherwise your code have not something to calculate any results.
4th Feb 2024, 7:49 AM
JaScript
JaScript - avatar
+ 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.
4th Feb 2024, 10:17 AM
Bob_Li
Bob_Li - avatar