+ 2
How to generate prime numbers in python using for loop in an interval with explanation starting from number 2 to max
3 ответов
+ 2
https://code.sololearn.com/cGT60z1q9qnw/?ref=app
here is code but I don't understand 2nd for loop how it print 2,3 because for i in range(2,2) don't work
+ 2
@choe else is outside for loop You mean to say that i is nothing so it will print 2
+ 1
when num is 2, i is nothing. Nested loops cant output these values, but the else on the loop is what is printing 2 since your condition inside wasnt satisfied.
for num in range(lower,upper+1):
for i in range(2,num):
if(num%i==0):
break
else:
print(num)
this should give you something different.