+ 1

Generators

(For the “Generators” practice) It passes the first three, but doesn’t pass the last one. What’s wrong with it? 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 for i in range(min(a,b), max(a,b)+1): if isPrime (i)== True: yield i f = int(input()) t = int(input()) print(list(primeGenerator(f, t)))

26th Sep 2023, 9:34 PM
Annihilate
Annihilate - avatar
1 Resposta
+ 2
Trey I believe that if you exclude the upper number of your range, you will pass all tests. for i in range(a,b): #will suffice
27th Sep 2023, 9:33 AM
Rik Wittkopp
Rik Wittkopp - avatar