On Wed, Nov 16, 2011 at 4:06 PM, Dario Lopez-Kästen <cl2dl...@gmail.com> wrote: > The indentation is indeed off: > Original code: > def PlotPathway(list1): > for i in range(len(list1)): > for j in range(len(list1[i])-1): > if list1[i][j] != list1[i][j+1]: > g.add_edge(list1[i][j], list1[i][j+1]) > > if list1[i][j]<=42: > g.node_attr.update(color='deepskyblue',style='filled') > if list1[i][j] > 42: > g.node_attr.update(color='green',style='filled') > > What I think you meant: > def PlotPathway(list1): > for i in range(len(list1)): > for j in range(len(list1[i])-1): > if list1[i][j] != list1[i][j+1]: > g.add_edge(list1[i][j], list1[i][j+1]) > > if list1[i][j]<=42: > g.node_attr.update(color='deepskyblue',style='filled') > if list1[i][j] > 42: > g.node_attr.update(color='green',style='filled') > > > Notice that I consistently use 4 spaces, and only spaces, not tabs, for each > indentation level. In your code (assuming the copy paste I did was correct) > I could see a mixture in the number of spaces for each indentation level. > The error was the python interpreted the second and third if statements as > being not properly indented, becuase of the lack of consitency: > > they did not align with the first if statement in side the for loop > the did not align with the for-loop either, so there could not be > intrepreted as being on the same level as the for loop.
Yes, it's lack of consistency, sorry, I thought I posted something like: if list1[i][j] != list1[i][j+1]: g.add_edge(list1[i][j], list1[i][j+1]) if list1[i][j]<=42: g.node_attr.update(color='deepskyblue',style='filled') if list1[i][j] > 42: g.node_attr.update(color='green',style='filled') The second and third if are inside the first if, it still complaining. I set the gedit, use space not tab, Now I even typed space by space, avoid using tab, it still has the same problem. How can I fixed it? I put the two files in below links: https://docs.google.com/open?id=0B93SVRfpVVg3NzlkMzVmOWYtNDk4MS00Yzk1LWEwMWQtYzIzMWU0Y2M2NmUz https://docs.google.com/open?id=0B93SVRfpVVg3ZDhiZjM1ZGItZDU0Ny00MDhhLThjZDQtYmRjMWJkMmVkNTk5 > > Hope this makes sense and helps! > Best regards, > /dario > On Wed, Nov 16, 2011 at 8:52 AM, lina <lina.lastn...@gmail.com> wrote: >> >> Why it keeps on complaining: >> >> $ python plot-pathway.py >> File "plot-pathway.py", line 35 >> if list1[i][j]<=42: >> ^ >> IndentationError: unindent does not match any outer indentation level >> >> >> def PlotPathway(list1): >> for i in range(len(list1)): >> for j in range(len(list1[i])-1): >> if list1[i][j] != list1[i][j+1]: >> g.add_edge(list1[i][j], list1[i][j+1]) >> >> if list1[i][j]<=42: >> g.node_attr.update(color='deepskyblue',style='filled') >> if list1[i][j] > 42: >> g.node_attr.update(color='green',style='filled') >> >> I checked the indentation very carefully, seems no problems. >> >> really no clue, >> >> Thanks with best regards, Thanks again, >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor > > > > > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor