Experiment with User input task of school

Back to General discussions forum

qwerty     2023-11-09 18:02:51

Hello, I was experimenting with "User input" task and got some strange results.

Look at this code:

a = io.read('*n')
b = io.read('*n')
print(a)
print(b)

When I enter 1 and 2 it outputs exactly these numbers.

Now look at this code:

x = io.read('*n')
y = io.read('*n')
print(x)
print(y)

When I enter 1 and 2 it outputs 2 and 2.

Can anyone explain me the difference, please?

Rodion (admin)     2023-11-11 12:02:50
User avatar

Ah, oh :) sorry, this input integration is most probably yet buggy - but this specific case looks extremely crazy. Perhaps it is about variable scope somewhre, I'll check.

This "School" thing actually is a seismic zone and only in its beginning, the link was made visible for blatant reason of indexing (which supposedly doesn't happen immediately).

But I'm quite thankful for cross-reviewing it, for hints and issue reports!

The whole thing is a consequence of observation upon struggles of few people who came to the site without experience with any programming. Earlier I thought it is not a big deal as anyone has vast internet with zounds of resources, but by and by I start feeling it may be better to try somehow patching this gap.

UPD yes, there was the variable x inside the function redefined as io.read, which was not local. Thanks once more, you saved me some time since I already hit this bug but mistaken it for something different and left it as is in bewilderment!

qwerty     2023-11-11 15:43:02

I see this bug is fixed now, thank you.

And thank you for bringing new content to the site! I'm pretty sure there was no "School" tab when I visited this site at previous week.

Please login and solve 5 problems to be able to post at forum