here below is my code

#!/usr/bin/python

#this is my third python script

print \
"""
this is a python program to figure out total sales price, including tax\n\n
\t\t\tprogrammed by\n
\t\t\tShane Lindberg\n\n
"""

base_price=int(raw_input("please enter the base price of the car:\n$"))
under_coat=int(1000)
stereo=int(200)
air=int(750)
tax=int(base_price*.07)

print "the total price of the car with all extras and tax is: $",base_price+under_coat+stereo+air+tax

this statement is not behaving in the way I think it would

print "the total price of the car with all extras and tax is: $",base_price+under_coat+stereo+air+tax

why is it adding a space after the "$" character like below

please enter the base price of the car:
$20000
the total price of the car with all extras and tax is: $ 23350

I would think it would be like this

$23350

not

$ 23350

Recommended Answers

All 2 Replies

The comma will automatically add a space. Better use this formatted print statement:

print "the total price of the car with all extras and tax is: $%d" % (base_price+under_coat+stereo+air+tax)

thanks :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.