how can make the Periods ring next to scientist (no space)

Question:

variable1 = "I"
variable2 = "plan"
variable3= "to"
variable4= "think"
variable5="like"
variable6= "a"
variable7="computer"
variable8= "scientist"
variable9= "."
print(variable1,variable2,variable3,variable4,variable5,variable6,variable7,variable8,variable9)

i got

I plan to think like a computer scientist .

i hope to get

I plan to think like a computer scientist.
Asked By: bingli

||

Answers:

There’re tons of ways to do this. One simple and adhoc way is

' '.join(['I', 'plan', 'to', 'think', 'like', 'a', 'computer', 'scientist', '.']).replace(' .', '.')
Answered By: Ricardo

You can use two print() calls, one to print the first 8 words separated by spaces, then another to print the .. Use end='' in the first call so it won’t go to a new line after it.

print(variable1,variable2,variable3,variable4,variable5,variable6,variable7,variable8, end='')
print(variable9)
Answered By: Barmar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.