RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 3457 | Replies: 2
Reply
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

statement adding extra space

  #1  
Jun 10th, 2005
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
not
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 2,548
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 11
Solved Threads: 178
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Solution Re: statement adding extra space

  #2  
Jun 10th, 2005
The comma will automatically add a space. Better use this formatted print statement:
[php]print "the total price of the car with all extras and tax is: $%d" % (base_price+under_coat+stereo+air+tax)
[/php]
May 'the Google' be with you!
Reply With Quote  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: statement adding extra space

  #3  
Jun 10th, 2005
thanks :-)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:57 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC