0

How do I change the default value of the , in the following code so that it does not insert a space

gas = int(input("How much have you spent on gas? "))
electric = int(input("How much have you spent on electric? "))
onlinePurchases = int(input("How much have you spent on online purchases? "))
total = gas + electric + onlinePurchases

print("Monthly Total: $", total)

The current code would print:

"Monthly total: $ *total*"

Is there a way to make it print:

"Monthly total: $*total*" 

I do not want a space between the dollar sign and the amount.

2 Answers 2

4

From python print docs:

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)

So you would want

print("Monthly Total: $", total, sep='')

Changing sep (separator) from a space to an empty string

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you and just so i know is "sep" short for "separation" and if not what does it stand for?
3

print("Monthly Total: ${0}".format(total))

or

print("Monthly Total: $%d" % total)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.