How to Print the Elements of any list or any loop in same row instead of printing it in different row? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to Print the Elements of any list or any loop in same row instead of printing it in different row?

17th Jan 2017, 2:51 PM
Gaurav
Gaurav - avatar
2 Answers
+ 1
The print function has an optional parameter called end which gives you the ability to literally, chose how you want to separate your arguments. alist = [ 1, 2, 3 ] for i in alist: print(i, end=' ')
18th Jan 2017, 1:04 PM
Don
Don - avatar
+ 1
Thanks a lot buddy
18th Jan 2017, 2:30 PM
Gaurav
Gaurav - avatar