+ 1
How to stop default new line in print statement?
While using print statement in a loop, every time the loop after encountering with the print statement the cursor is shifted to the next line. Can I do something to avoid this. Anything that switches this escape sequence temporarily?
4 Réponses
+ 12
print(x , end =" ")
This will give the output in a single line
+ 4
well I think that depends on which language u use like
1. In C we have printf(); prints in the same line under the condition u are talking about unless \n is used
2.in C++ its similar to C except that we use cout and endl or \n for next line
3.in java if we use
System.out.print(); we keep on getting output on the same line
if we use System.out.println(); we get output in the next line
+ 4
can't comment for other languages...
0
I was asking for python.