How to add a space between words in a string in Python

In this Answer, we will look at multiple ways of adding space between words in a string using Python.

Approaches

  • join(): If we get the input as a list of words, we can add space between the words using the join() method.

  • +: We can add two strings using the + operator.

  • f: We can add space between words and get a new string using f strings syntax.

  • print: We can add spaces between words by listing them as commas separated in the print() statement.

Code examples

  1. We add spaces between words using the join() method, which accepts a list and returns a string.

list_of_words = ["Apple", "Banana", "Orange"]
#example using join()
print(" ".join(list_of_words))
  1. We can use + operator to concatenate two strings. So, we add space between words by concatenating them with an empty string containing a space.

word1 = "Blue"
word2 = "Green"
#example using + operator
print(word1 + " " + word2)
  1. We can dynamically provide values in strings using variables in f strings. So, we add space after each word in an f string.

word1 = "Blue"
word2 = "Green"
#example using f strings
print(f"{word1} {word2}")
  1. A print statement adds a space after each word specified in the statement, separated by commas.

word1 = "Blue"
word2 = "Green"
#example using print statement
print(word1, word2)

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved