-1

old newbie in Python, and I came across a problem.

print('Adding the two numbers gives',user_num,', which is different from',str(number1 + number2),'.')

output:

Adding the two numbers gives 24 , which is different from 1212 .

Question: How do you remove the space between 24 and the comma, and the space between 1212 and .?

blhsing
  • 91,368
  • 6
  • 71
  • 106
devil0108
  • 37
  • 1
  • 1
  • 6
  • DSM's answer to the duplicate questions covers most of the options. If you're using Python 3.6 or later, the one you want is probably the f-string: `print(f'Adding the two numbers gives {user_num}, which is different from {number1 + number2}.')`. – abarnert Sep 10 '18 at 01:52

1 Answers1

0

You can specify a separator to print with the sep keyword argument. To remove separators altogether, make it an empty string.

print(number1, number2, sep='')
Olivier Melançon
  • 21,584
  • 4
  • 41
  • 73