Programming Tip -How can we combine multiple print statements per line in Python?

in #utopian-io7 years ago

Programming Tip -How can we combine multiple print statements per line in Python?

EBOOK_PYTHON_no-name.png


Today i am going to show Programming Tip - How can we combine multiple print statements per line in Python
with simple code. I hope you will understand this.
If you have any query you can ask.
i hope you will like it.


Python2.x
print "Hello",
print " world"

Python3.x
print ("Hello", end='')
print (" world")


This will give the output:

Hello world
Another thing you could do is put all the things in an array and call ''.join(array). For example,

arr = ["Hello", "world"]
print(' '.join(arr))
This will give the output:

Hello world


Follow me at : https://steemit.com/@ahmadhassan
=========================================================


Thanks for reading and always welcome your suggestions :) =========================================================

Sort:  

I like using ''' for multi-line prints :)

that's great. every programmer has own way to program. :) Thanks for your feedback

This post has received a 1.33 % upvote from @booster thanks to: @ahmadhassan.

Coin Marketplace

STEEM 0.21
TRX 0.25
JST 0.038
BTC 97111.20
ETH 3382.29
USDT 1.00
SBD 3.20