-3

I want to print How do you like python so far? in python 3. But when I run my code there is no spaces between my strings. What should I do?

word1 = "How"
word2 = "do"
word3 = "you"
word4 = "like"
word5 = "Python"
word6 = "so"
word7 = "far?"

print(word1+word2+word3+word4+word5+word6+word7)

4 Answers4

2
print(f'{word1} {word2} {word3} {word4} {word5} {word6} {word7}')
Rob Kwasowski
  • 2,690
  • 3
  • 13
  • 32
1

You can add a space string in between or can use f-string

print(f'{word1} {word2} {word3} {word4} {word5} {word6} {word7}')
Abdul Mateen
  • 94
  • 1
  • 5
  • Duplicated with another earlier answer here https://stackoverflow.com/a/63700384/248616. Thanks any way! – Nam G VU Sep 02 '20 at 07:43
0

You can replace + to ,

print(word1,word2,word3,word4,word5,word6,word7)
0

keep spaces in your print statments if you wanna use string + string and add space use this

print(word1+''+word2+''+word3+''+word4+''+word5+''+word6+''+word7)

But its is much easier to use f strings as shown below

Noel G
  • 116
  • 6