how complete ask generater | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

how complete ask generater

I canā€™t solve the ā€œgeneratorā€ task in Python Divoloper, I have the code presented below, it passes 4 out of 5 tests, but the 5th hidden one doesnā€™t pass, whatā€™s the problem? asks: Finding prime numbers is a common coding interview task. The given code defines a function isPrime(x), which returns True if x is prime. You need to create a generator function primeGenerator(), that will take two numbers as arguments, and use the isPrime() function to output the prime numbers in the given range (between the two arguments). Sample Input 10 20 Sample Output [11, 13, 17, 19] 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 num in range(a,b+1): if isPrime(num): yield num f = int(input()) t = int(input()) print(list(primeGenerator(f, t)))

6th Oct 2023, 8:23 PM
Š”ŠµŃ€Š³ŠµŠ¹ Š“Š°Š²Ń€ŠøŠ»Š¾Š²
Š”ŠµŃ€Š³ŠµŠ¹ Š“Š°Š²Ń€ŠøŠ»Š¾Š² - avatar
5 Respostas
+ 4
All of your lines are correct except line 13
6th Oct 2023, 9:02 PM
Annihilate
Annihilate - avatar
+ 3
What Trey said, because Sololearn was literal when they wrote "in the range of" whatever. Also, just a formatting suggestion: Move that empty line currently separating your primeGenerator function's definition from its body to below the function, so that it separates the function from the input statements instead. Also, maybe add a python tag.
6th Oct 2023, 10:26 PM
Rain
Rain - avatar
+ 3
In my opinion, your code should pass all tests...šŸ¤”
7th Oct 2023, 12:05 AM
Solo
Solo - avatar
+ 3
Solo You are correct in saying that the code will run successfully, but the challenge won't accept the upper limit of the range being included in the output.
7th Oct 2023, 5:07 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp, yes, but it is also written in the task that the list should consist of numbers in the interval between the specified ranges, that is, the extreme number of the range should not be taken into account.
7th Oct 2023, 8:37 AM
Solo
Solo - avatar