Python Forum

Full Version: loop within loop confusion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying out nested loops. I included the error message I get at the end. I simply cannot see how indentation is inconsistent. Please help

#Program loops
start_for = 3
end_for = 102

for c in range(start_for, end_for,2):
    for x in range(3,10,2):
        remainder=c%x
        if remainder > 0:
            for y in range(2,10):
                remainder = c%y
				if remainder != 0:
                    print(c)
 
print("end program")
#line 15
#if remainder != 0: #TabError: inconsistent use of tabs and spaces in indentation ^
(Feb-03-2019, 12:46 PM)anfaenger Wrote: [ -> ]I simply cannot see how indentation is inconsistent.

We also cannot see as you didn't use Python tags and there is no intentation.
you mix tabs and spaces for indentation and that is why you get the error. The recommendation is to use spaces (4 spaces).
Most IDE would have option to convert tabs to spaces automatically.
Thank you Buran, you identified the problem. I didn't use tags because I've no idea what they are and how to use them. And yes, I've read the explanation.