Ask coding questions

← Back to all posts
Have a problem with only this IDE.
thongth (0)

This program works very well on another site but it keep failing when I tried to run it on this site. (it doesn't print out the result in line 2 in the given picture) Is there any reasons to this?
You can try it yourself if you want to.
Ps. The picture shows how I want the program to be. (And it was on another site)

Answered by JoshDaBosh (76) [earned 5 cycles]
View Answer
Commentshotnewtop
JoshDaBosh (76)

@thongth change the last 2 lines to just this:
print(*lisR, sep=" ")

thongth (0)

@JoshDaBosh Wow, It really works. Do you have any idea why it didn't print anything at first whilst others did.

JoshDaBosh (76)

@thongth it's something to do with the end=" " and how repl.it handles it. (I was super confused as well lol)
The "*" in my line is just python "shorthand" for all elements in that list. I've tried using end="\n" and sep=" " in your original code's last line and it works.
Repl.it is funny sometimes :\

amasad (1742)

@JoshDaBosh Sorry about that. It shouldn't be funny at all. We'll fix it today. Let us know here or email me directly if anything is ever funny [email protected] (I'm the ceo)

pyelias (925)

This seems to have something to do with newline buffering. Add a print() after and it'll work fine.

OwenBradstreet (84)

@pyelias You can also set the flush argument to true flush=True inside the print, which forces the terminal to buffer after each one :)

amasad (1742)

hey all, pushing a fix for this in an hour. Repl.it should always do the right thing, and we're very sorry for this bug.

timmy_i_chen (1005)

Correction: this should be fixed soon! Will ping as soon as it's fixed.

timmy_i_chen (1005)

Thanks for helping guys, @thongth the end=" " is a known problem and will be fixed as soon as we ship the new terminal (almost released) :)

JoshDaBosh (76)

What's the error? If it's the print statement giving you issues, try switching to python3 instead of python2.