Indenting issue

10 views
Skip to first unread message

Bruce Sherwood

unread,
Sep 1, 2017, 10:10:47 AM9/1/17
to Glowscript Users
A student program had a loop that looked like this:

n = 0
while n < 6:
print(n)
n += 2
print('Done')

This was interpreted by the RapydScript-NG transpiler as though it had been written like this:

n = 0
while n < 6:
    print(n)
    n += 2
    print('Done')

when the student had really meant

n = 0
while n < 6:
    print(n)
    n += 2
print('Done')

When I reported this to Kovid Goyal, the developer of RapydScript-NG, he immediately fixed the bug, Now if there is nothing indented you get an error message "Expected an indented block".

You can still put statements on the same line as the colon:

if n == 6: n = -8; n = 3

(Python lets you chain statements together if separated by a semicolon.)


Reply all
Reply to author
Forward
0 new messages