+ 1
Please check my code, where is the error and can remove ??
lower = int(input("enter lower range:")) upper = int(input("enter upper range:")) for num in range(lower, upper+1): if num > 1: for i in range (2,num): if (num % i) == 0: break else : print (num)
6 Answers
+ 2
lower = int(input("enter lower range:"))
upper = int(input("enter upper range:"))
for num in range(lower, upper+1):
if num > 1:
for i in range (2,num):
if (num % i) == 0:
break
else :
print (num)
OR
lower = int(input("enter lower range:"))
upper = int(input("enter upper range:"))
for num in range(lower, upper+1):
if num > 1:
for i in range (2,num):
if (num % i) == 0:
break
else :
print (num)
I can't get what your trying to do... so I can't know hiw it should be indented.
+ 1
For one, the indentations are off... your for loop is indented and your if block is dedented, whereas I believe your intention was to run the 'if' inside the for loop... same is the case with second for loop and if/ else
+ 1
it is generally a good idea to describe in which way the code is not right, and what you expect instead..:-)
+ 1
the indentation in your example code here is not right
0
how can I remove this indentation??
0
lower = int(input("enter lower range:"))
upper = int(input("enter upper range:"))
for num in range(lower, upper+1):
if num > 1:
for i in range (2,num):
if (num % i) == 0:
break
else :
print (num)