Newbie: unexpected indenting error
Denis McMahon
denismfmcmahon at gmail.com
Sun Jul 13 20:14:08 EDT 2014
On Sun, 13 Jul 2014 09:01:12 +0200, Martin S wrote:
> While coding a rating calculator I am using a for-loop within
> if-elif-else.
> When using the for-loop in the first if instance my editor accepts this,
> but when using the same for-loop within the elif instance it complain
> about "unexpected indent".
>
> Like so:
>
> def function(x):
> if rdiff >=500:
> for ....
> [do stuff]
> elif rdiff >=410:
> for ... <== unexpected indent
> [do other stuff]
>
>
> What the...? What am I doing wrong?
> (hopefully the indents translate; else def, if/elif, for and [dostuff]
> are indented)
You seem to have posted what you believe is an equivalent structure to
your code, rather than your actual code.
The structure you have posted looks fine, but it's not a runnable snippet
that we can actually test.
Can you actually reproduce the problem in a single block of code that we
can try and run ourselves?
For example, if you copy your "problem" function to a new file and edit
the function def line and the code and lines after the for statements as
follows, does the problem persist?
for rdiff in range( 450, 600, 100 ):
if rdiff >=500:
for i in range( 1, 3 ):
print rdiff, i
elif rdiff >=410:
for i in range( 1, 3 ):
print i, ridff
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list