How to print in same line in Python

How to print in same line in Python

The Python’s print() function is used to print the result or output to the screen. By default, it jumps to the newline to printing the next statement. It has a pre-defined format to print the output. Let’s understand the following example.

Example – 1

Output:

Welcome
To
JavaTpoint

Or, we can write the complete statement in single print() function.

Output:

Welcome To JavaTpoint

The Python print() function has an argument called end, which prevents jump into the newline. Let’s understand the following example.

Example – 3:

Output:

10 11 12 13 14 15

In the above code, we declared a list and iterated each element using for loop. The print() function printed the first element of the list and then printed the end value which we assigned as ‘ ‘ whitespace and it will be printed till the element of the list.

We can assign any literal to the end. Let’s understand the following example.

Example – 4

Output:

10&11&12&13&14&15&

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263620.html

(0)
上一篇 2022年5月30日
下一篇 2022年5月30日

相关推荐

发表回复

登录后才能评论