[Tutor] Basic question on spaces
Alexander Quest
redacted@example.com
Wed Jul 20 05:39:01 CEST 2011
Hello; I'm a new student of Python using "Python Programming for Absolute
Beginners" 3rd edition by Michael Dawson as my guide. This is a basic
question regarding spaces. I'm not sure how to make it so spaces do not show
up between variables and basic strings, particularly before commas and after
dollar signs, as in the simple "tipper" program I have below.
____________________________
#Tip program: calculates 15% and 20% tip for a given bill.
bill = int(input("Hello! Welcome to the tipper program. \nWhat is the amount
of "
"your bill, in dollars please: "))
percent15 = bill * .15
percent20 = bill * .20
print("\nOkay, based on that bill, a 15% tip would be $", percent15, ", and
\n"
"a 20% tip would be $", percent20, ".")
input("\n\nPress the enter key to exit.")
____________________________
As you can see, this is quite rudimentary; I have not discovered any special
function that eliminates spaces yet, if such a function exits. The problem
is, as stated above, unwanted spaces after both dollar signs, before the
comma after '15.0' and before the period after '20.0." Apologies for asking
such a basic question, but any help will be appreciated.
-Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110719/3258cf79/attachment.html>
More information about the Tutor
mailing list
l>