Python Forum
Printing on same line from 2 functions.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing on same line from 2 functions.
#2
First of all, you are using Python 2.7. End of life for Python 2.7 is at the end of the month. You should really upgrade to Python 3.7.

To answer your question, to print without going to the next line in 2.7, you use a trailing comma:

for spam in range(5):
    print 'spam',
In 3.0+, print is a function, and you use the end parameter to specify no new line at the end:

for spam in range(5):
    print('spam ', end = '')
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Printing on same line from 2 functions. - by ichabod801 - Dec-03-2019, 02:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Seven Segment Display - QUERY on Multi-line side-by-side printing output ajayachander 3 4,872 Mar-13-2020, 07:02 AM
Last Post: ajayachander
  Command line inputs not printing to Log File ijosefson 1 3,377 Oct-19-2017, 06:41 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020