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

Time:02-04

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.

CodePudding user response:

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)

CodePudding user response:

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

' '.join(['I', 'plan', 'to', 'think', 'like', 'a', 'computer', 'scientist', '.']).replace(' .', '.')
  • Related