Python Forum
loop within loop confusion - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: loop within loop confusion (/thread-15851.html)



loop within loop confusion - anfaenger - Feb-03-2019

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 ^


RE: loop within loop confusion - perfringo - Feb-03-2019

(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.


RE: loop within loop confusion - buran - Feb-03-2019

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.


RE: loop within loop confusion - anfaenger - Feb-03-2019

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.