Python Basic- using print statement to display in single line


In python it the print statement prints the string and moves to next line by default … but sometime it is required to print multiple values in a single.

One way is use a variable and append it or
Just put the ‘,’ at the end of print

if __name__ == '__main__':
print 'hello',
print 'world'

2 thoughts on “Python Basic- using print statement to display in single line

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s