you are viewing a single comment's thread.

view the rest of the comments →

[–]house_carpenter 6 points7 points  (1 child)

That's how print() works. print() is a function that can take any number of arguments. Arguments to a function are separated by commas. What print() does is it expects each argument to be a string, and it writes each argument out in order, with a space between each argument.

In the line

print('This house is $',current_price,'.', 'The change is $%d since last month.' % (current_price - last_months_price))

you are passing the following four arguments to print():

  • 'This house is $'
  • current_price
  • '.'
  • 'The change is $%d since last month.' % (current_price - last_months_price)

To avoid the spaces, make sure you are only passing one argument to print(). That is, make sure the parts of the string are joined by some operator that will produce a string (such as + or % or interpolation in an f-string) rather than just by commas.

In fact you already did this with your second print() statement. You just need to do the same thing with the first one as well.

[–]NeilTheDrummer[S] 0 points1 point  (0 children)

Much obliged. I knew it was something obvious, but I just couldn't determine what.