This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author victorywin
Recipients victorywin
Date 2011-03-07.16:54:43
SpamBayes Score 2.2385132e-09
Marked as misclassified No
Message-id <1299516884.35.0.66577076049.issue11433@psf.upfronthosting.co.za>
In-reply-to
Content
Hi and please help me understand if it is a bug, or..,as someone said, there's a 'bug' in my understanding:
(Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32) (windows vista, the regular windows python installer)
It's about the following code:

while True:
    s = input('Enter something : ')
    if s == 'quit':
        break
    print('Length of the string is', len(s))
print('Done')

when I put it in the IDLE's editor, and run it from there ("Run module F5"), it runs fine; but when I try to type it in the python shell (IDLE), or in the python command line, it gives errors, though I tried to edit it differently:

>>> while True:
        s = input('Enter something : ')
        if s == 'quit':
            break
        print('Length of the string is', len(s))
print('Done')
SyntaxError: invalid syntax
>>> while True:
        s = input('Enter something : ')
        if s == 'quit':
            break
        print('Length of the string is', len(s))
    print('Done')
SyntaxError: unindent does not match any outer indentation level
>>>

The only way I noticed it would accept is to set the last "print" statement directly under/in the block of "while": which is not the intention. (According to the docs, while statement should work without the "else" option). Is this a bug?
Thanks, Victor
p.s. the example is taken from http://swaroopch.com/notes/Python_en:Control_Flow
History
Date User Action Args
2011-03-07 16:54:44victorywinsetrecipients: + victorywin
2011-03-07 16:54:44victorywinsetmessageid: <1299516884.35.0.66577076049.issue11433@psf.upfronthosting.co.za>
2011-03-07 16:54:43victorywinlinkissue11433 messages
2011-03-07 16:54:43victorywincreate