Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 loop within loop confusion
#1
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 ^
buran wrote Feb-03-2019, 12:48 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Quote
#2
(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.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Life of Brian: Conjugate the verb, "to go" !
Quote
#3
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.
Quote
#4
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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Operations on indexed variables in loop Fibulavie 1 67 Aug-14-2019, 06:07 AM
Last Post: fishhook
  how do i loop a "def ..." when error occurs? Stan2292 0 55 Aug-12-2019, 05:28 AM
Last Post: Stan2292
  Get all values of for loop with an index BollerwagenIng 2 142 Aug-09-2019, 07:58 AM
Last Post: BollerwagenIng
  Setting maximum value of Range() in For loop pmt 4 205 Aug-04-2019, 02:38 PM
Last Post: pmt
  While loop kasper1903 4 207 Aug-03-2019, 06:27 PM
Last Post: jefsummers
  How can I sort my names of files in for loop? Mike Ru 2 125 Aug-02-2019, 04:56 AM
Last Post: perfringo
  Loop through List jeran042 5 138 Jul-30-2019, 05:25 PM
Last Post: ichabod801
  Loop do not start for letter matching algoritm phob0s 3 121 Jul-29-2019, 04:31 PM
Last Post: ThomasL
Question Why does modifying a list in a for loop not seem to work? umut3806 2 167 Jul-22-2019, 08:25 PM
Last Post: umut3806
  Confusion in exact term used for ? ift38375 2 122 Jul-22-2019, 08:58 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)