close

How do I put a space between two string items in Python

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How do I put a space between two string items in Python in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How do I put a space between two string items in Python?

  1. How do I put a space between two string items in Python?

    The default for print, however, is to put a space between arguments, so you could also do:
    print(item1, item2)

  2. put a space between two string items in Python

    The default for print, however, is to put a space between arguments, so you could also do:
    print(item1, item2)

Method 1

Use .join():

print(" ".join([item1, item2]))

The default for print, however, is to put a space between arguments, so you could also do:

print(item1, item2)

Another way would be to use string formatting:

print("{} {}".format(item1, item2))

Or the old way:

print("%s %s" % (item1, item2))

Method 2

# works every time
print(item1, item2)
# Only works if items 1 & 2 are strings.
print(item1 + " " + item2)

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read