+ 1

what should i do with this code to recive non empty list!?

https://www.sololearn.com/compiler-playground/cmZL5T18jfPU

4th Jan 2023, 4:12 PM
Nariman Tajari
Nariman Tajari - avatar
5 Respuestas
+ 2
First isPrime function has one parameter. Second isPrime function return a bool: true or false. Now you can think again about, how can the code be corrected.
4th Jan 2023, 6:20 PM
JaScript
JaScript - avatar
+ 2
Why you write i+=1 in the for loop?
4th Jan 2023, 9:55 PM
JaScript
JaScript - avatar
+ 1
i rewrite this code like this @JaScript but i donnow how i make the list output: 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 a = int(input()) b = int(input()) i=[] def primeGenerator(a, b): #your code goes here for i in range(a,b): i+=1 if isPrime(i): print(i) primeGenerator(a,b)
4th Jan 2023, 7:46 PM
Nariman Tajari
Nariman Tajari - avatar
+ 1
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 a = int(input()) b = int(input()) i=[] def primeGenerator(a, b): #your code goes here for i in range(a,b): i+=1 if isPrime(i): yield(i) print(list(primeGenerator(a,b)))
4th Jan 2023, 8:23 PM
Nariman Tajari
Nariman Tajari - avatar
+ 1
i write it from last commit i forgot to delete that.
4th Jan 2023, 9:58 PM
Nariman Tajari
Nariman Tajari - avatar