Input | SoloLearn: Learn to code for FREE!

+2

Input

Why do we have to write the inputs just before the program runs?

3/28/2018 1:57:51 PM

Al_

5 Answers

New Answer

+2

Inputs from user are required to be done all at once just before running the code, due to how codes are handled in code playground (except for web project) : code are running on server side, not locally, so in/output are buffered... inputs need to be collected at start to be send with code on server side, and outputs are collected on server side during code execution and returned to user side for displaying after code end ;) For web project, code is first send to server side, but then executed on user side after reloaded as normal http request (because that's the usual way to handle web code, without requiring compiler/interpreter to be installed and able to be handled from app' or browser)...

+1

https://code.sololearn.com/WhiNb9BkJUVC/?ref=app

+1

No you can write them anywhere as per your need.

0

I think it's the fault of the in-built python console of SoloLearn. Because the same line of code with an IDE works fine. I mean after defining a variable which need an input, the running of the code stops and wait for this input before go further. Is it correct?

0

No! Even if you put the inputs at the end you will get the popup before the code runs.