Message130261
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 |
|
Date |
User |
Action |
Args |
2011-03-07 16:54:44 | victorywin | set | recipients:
+ victorywin |
2011-03-07 16:54:44 | victorywin | set | messageid: <1299516884.35.0.66577076049.issue11433@psf.upfronthosting.co.za> |
2011-03-07 16:54:43 | victorywin | link | issue11433 messages |
2011-03-07 16:54:43 | victorywin | create | |
|