0
Code can't run in sololearn playground!!
I have a simple snippet of code that runs perfectly in my IDE, But when I try it in sololearn playground it produces (no output) Where is the problem???đđ€ #! python3 import time import sys indent = 0 # how many spaces to indent indentIncrease = True # whether the indentation is increasing or not try: while True: print(" " * indent, end="") print("*" * 8) time.sleep(0.1) # pause if indentIncrease: indent += 1 if indent == 20: indentIncrease = False else: indent -= 1 if indent == 0: indentIncrease = True except KeyboardInterrupt: sys.exit()
4 Answers
+ 4
Program on sololearn runs on a remote server which unlike your machine only allocates limited time for your program to run ( around a second or so )
The problem in your program is that it is exceeding time limit while in the pause state and as the program is terminated like this, the output buffer is not flushed to stdout leading to "no output".
The 2 possible fixes of this is to either remove the ( time.sleep() ) from your program or flush the buffer before it.
Here is a probable fix đ
https://code.sololearn.com/csRVa57ys083/?ref=app
( Keep in mind that program will still not run indefinitely because of time limit imposed by SL )
+ 2
It's because your loop is infinite and the only way to break out of it is a keyboard interrupt, which isn't possible in the SL playground.
+ 2
Awesome,
I got it
Thank you very muchđđ
0
Thanksđđ
I thought it was because sys module