0

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
2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by shanenin
0

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)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.