+ 1

Pausing a program in python and wait for input

I would like to pause my program and ask for some input and execute the next part of the program... something like below... 1.Start the python program. 2.Do some stuff 3.Pause -> Wait for the user to execute some commands. The script will keep waiting if the user does not input anything. 4.Continue -> Continue execution of the remaining part of the script.

30th Sep 2017, 8:21 AM
ARC
ARC - avatar
4 Answers
+ 4
Did you try to do so in code playground? This particular context of running Python scripts doesn't allow real in/output interactivity, as scripts are running on sololearn servers: whole required input needed is send to server before running script, and output is buffered on server side and send after script end running ^^ If you need real in/output interactivity, you need to run Python in another context: try some Python apps for mobile as QPython (3) for android, or use desktop Python interpreter ;)
30th Sep 2017, 10:52 AM
visph
visph - avatar
+ 1
Thanks visph :-)
30th Sep 2017, 11:14 AM
ARC
ARC - avatar
0
I think I need to rephrase my question for clarity. 1. Start python 2. Enter first input 3. Run the query 4. Enter second input 5. Run the remaining part of the query My question is how can I enter input in step 4 after depending on some condition encountered in step 3. I would like to know if there is any way I could make the query pause after 3 and wait till I enter the second input at step 4.
30th Sep 2017, 10:24 AM
ARC
ARC - avatar
0
I used Qpython3 with the following code and the result was perfect. I understand that it was a Sololearn specific issue. #My code print("Hello Bro") name = input("Please enter your name: ") print ('\t',name, "is the name") print ("Ok! Next Step") age = input ("Please enter your age: ") print ('\t', "The age of", name, "is", age) #Thanks everyone for their help
1st Oct 2017, 2:22 AM
ARC
ARC - avatar