def isPrime(x):
if x < 2:
return False
elif x == 2:
return True
for n in range(2, x):
#this part confuses me
if x % n ==0:
return False
return True
#i know generators but i dont understand whats going on here
def primeGenerator(a, b):
#your code goes here
for n in range(a, b):
if isPrime(n):
yield n
f = int(input())
t = int(input())
print(list(primeGenerator(f, t)))
Could you comment the code with indents? it will be easier to read if you include them.
I’ve made sure to indent the comments as well as the code, but it seems that when it is posted, everything gets realigned. I’m quite new as well so maybe I just don’t know how to do so.
try putting it in a code block, you can press the “preformatted text”(</>) button, or you can press the back tick (`) three times and paste your code in that.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.