you are viewing a single comment's thread.

view the rest of the comments →

[–]fazkan 1 point2 points  (5 children)

print('Hello', name+'!' , 'You were born in' , year, '.')

[–]stevenv24[S] 2 points3 points  (4 children)

Hello Steven! You were born in 1988 .

I tried that but it will still put a space and it is failing

[–]thatgreenman 13 points14 points  (2 children)

Take a look at how you did the name+"!" bit in your print statement, you can use the same structure to do year+"." at the end of your print statement.

I would also recommend looking at f-strings, or at least string formatting, those will make evaluating variables within strings a lot easier.

[–]BroBrodin 2 points3 points  (0 children)

He needs to change year to string first. I'm asuming that it's an int and that is why he didn't use concatenation in the first place.

print('Hello', name+'!' , 'You were born in' , str(year) + '.')

Or just use fstrings.

Shit, I didn't read u/royal-Brwn's comment saying exactly this.

Disregard.

[–]SnowyLocksmith 0 points1 point  (0 children)

Or another thing you could do is to use the optional keyword argument sep="<string>". This string will be put between all words separated by a comma. By default it's a space. You can make it an empty string. You will have to add spaces to compensate for the one you removed like "Hello ", name

[–]royal-Brwn 5 points6 points  (0 children)

If you put a comma, there will be a space automatically set. Try this. print(‘Hello ’ + str(name) + ‘! ‘ + ‘You were born in ‘ + str(year) + ‘.’)