How to print in Same line in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

How to print in Same line in Python

In python if I'm using for loop to print some numbers. So how will I print all the numbers in the same line. for example 123456789 instead of 1 2 4 5 6 please help guys

14th Aug 2018, 5:27 PM
Devender Kumar
Devender Kumar - avatar
2 Answers
+ 7
In Python 3, printing is a function. When you call print ('hello world') Python translates it to print ('hello world', end = '\n') You can change end to whatever you want. print ('hello world', end = '') print ('hello world', end = ' ')
14th Aug 2018, 5:40 PM
Detlef
Detlef - avatar
+ 6
thanks Detlef
15th Aug 2018, 6:05 AM
Devender Kumar
Devender Kumar - avatar