0

I am doing a simple program in python for my class, and I basically have it down except I can't figure out how to make the dollar sign appear right next to the sum without leaving a space. This is my code:

item1 = input("Enter price of first item: $");
item2 = input("Enter price of second item:$");
item3 = input("Enter price of third item: $");
total = (item1 + item2 + item3);
print("The total of the three items is:$", total);

1 Answers1

0

Try

print("The total of the three items is:${}".format(total))

If in python 3.6 or above, you can also use f-Strings:

print(f"The total of the three items is:${total}")

The "old fashioned way" would be to use the %s formatter:

print("To total of the three items is:$%s" % total)
sacuL
  • 49,704
  • 8
  • 81
  • 106