+ 1

Hey, I need help solving this problem!

I have encountered an issue, and I'm not able to continue my course since it seems to be a bug with this problem: The given code takes the two arguments as input and passes them to the generator function, outputting the result as a list. def isPrime(x): if x < 2: return False elif x == 2: return True for n in range(2, x): if x % n ==0: return False return True def primeGenerator(a, b): #your code goes here f = int(input()) t = int(input()) print(list(primeGenerator(f, t))) my solution was this: def isPrime(x): if x < 2: return False elif x == 2: return True for n in range(2, x): if x % n ==0: return False return True def primeGenerator(a, b): for number in range(a, b + 1): if isPrime(number): yield number f = int(input()) t = int(input()) print(list(primeGenerator(f, t))) And it passes the first 3 test, but the 4th does not pass and does not give any info about why it's not passing, so I can correct it. Appreciate all the help!

15th May 2024, 10:37 PM
Santiago Rodriguez
5 odpowiedzi
+ 6
Santiago Rodriguez , the task description says ...to output the prime numbers in the given range (**between the two arguments**) so if we omit the `+1` in the range() function of your code it will pass all test cases.
16th May 2024, 5:35 PM
Lothar
Lothar - avatar
16th May 2024, 8:21 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 3
Maybe the issue is with range(a, b+1) It is not clear from your description, if b should be included or not.
16th May 2024, 6:31 AM
Tibor Santa
Tibor Santa - avatar
+ 2
To me, this looks correct. Do you have any idea what the fourth test is?
16th May 2024, 1:41 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 2
It worked, thank you all for the help and tips!!
16th May 2024, 7:07 PM
Santiago Rodriguez