In C++ or any other languages, you can write programs that continuously take input lines from stdin and output the result after each line. Something like:
while (true) {
readline
break if eof
print process(line)
}
I can't seem to get this kind of behavior in Python because it buffers the output (i.e. no printing will happen until the loop exits (?)). Thus, everything is printed when the program finishes. How do I get the same behavior as with C programs (where endl flushes).