+ 4

Is there a maximum number of lines in Python output ?

I'm writing a code that'll have to output many things so I wondered if there was a maximum number of lines for Python ?

13th Jul 2022, 12:48 PM
Raheray
Raheray - avatar
9 Respuestas
+ 6
When I tried, it printed 10000 lines, but not 100000 lines… Maybe it’s conected to the execution time. So, for example, because a for loop is faster then a while loop, you can print out more lines with a for loop. But that’s just a hypothesis 🙂.
13th Jul 2022, 2:25 PM
Per Bratthammar
Per Bratthammar - avatar
+ 4
I don't believe sololearn has output limits, but it definitely has time limits. I believe sololearn also collects the output and, if your code times out, sololearn only returns a portion of the output. 19 Jul edit: Per Bratthammar subsequently proved that sololearn does have output limits
13th Jul 2022, 2:20 PM
Steve
Steve - avatar
+ 3
Hi, Raheray ! Can’t you try figure it out by yourself? Try run: n = 10000 for i in range(n): print(i) and see how long time you can increase the number n.
13th Jul 2022, 2:19 PM
Per Bratthammar
Per Bratthammar - avatar
+ 3
HI, Alba Robledo ! Well, 100 lines are a small number in this context. I ran the two code lines below on SoloLearns app on my iPhone, and it printed out 18517 lines, but not more. n = 18518 for i in range(n): print(i)
13th Jul 2022, 8:06 PM
Per Bratthammar
Per Bratthammar - avatar
+ 2
In SoloLearn time of execution runs out quick, I guess this is in order to not overload mobile devices. I'd say around 100 lines
13th Jul 2022, 6:13 PM
Alba Robledo
Alba Robledo - avatar
+ 2
Per Bratthammar I was able to confirm the 18518 number with this code: print(*[n for n in range(15818)],sep='\n') Which I wouldn't expect to perform the same as your code. https://code.sololearn.com/c4Fu1s5v7Xj3/?ref=app
14th Jul 2022, 11:20 AM
Steve
Steve - avatar
+ 2
Raheray , Per Bratthammar , and Alba Robledo I think the actual limit is 100000 characters. https://code.sololearn.com/cYxC4N59mE2H/?ref=app
14th Jul 2022, 6:18 PM
Steve
Steve - avatar
+ 1
Are you asking about the language itself, or about running python code within sololearn?
13th Jul 2022, 1:24 PM
Steve
Steve - avatar
+ 1
About Python with Sololearn
13th Jul 2022, 1:42 PM
Raheray
Raheray - avatar