Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60784
| Date | 2013-11-29 18:53 -0600 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: Need help with programming in python for class (beginner level) |
| References | <e9d18514-1da5-471a-bf39-5f67d3d8fef7@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3411.1385772707.18130.python-list@python.org> (permalink) |
On 2013-11-29 16:31, farhanken@gmail.com wrote:
> It's for a school assignment.
Thanks for the honesty--you'll get far more helpful & useful replies
because of that. :-)
> put them into a variable I called "number" but it seems to glitch
> out that variable is in any command other than "print number".
> Like, if I try to write:
>
> print "<p>your total number was:" number "</p>"
>
> It just doesn't work.
You're so close. Python doesn't let you directly combine strings and
numbers like that, especially without any operator. However it does
offer several ways to combine strings:
print "convert to string and use " + str(number) + " a '+' operator"
print "use %s classic C-style formatting" % number
print "use new {} formatting style".format(number)
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Need help with programming in python for class (beginner level) farhanken@gmail.com - 2013-11-29 16:31 -0800 Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 01:38 +0100 Re: Need help with programming in python for class (beginner level) Eduardo A. Bustamante López <dualbus@gmail.com> - 2013-11-29 16:45 -0800 Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 01:49 +0100 Re: Need help with programming in python for class (beginner level) Tim Chase <python.list@tim.thechases.com> - 2013-11-29 18:53 -0600 Re: Need help with programming in python for class (beginner level) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-30 00:59 +0000 Re: Need help with programming in python for class (beginner level) Tim Chase <python.list@tim.thechases.com> - 2013-11-29 19:06 -0600 Re: Need help with programming in python for class (beginner level) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-30 01:08 +0000 Re: Need help with programming in python for class (beginner level) Johannes Findeisen <mailman@hanez.org> - 2013-11-30 02:16 +0100 Re: Need help with programming in python for class (beginner level) Julio Schwarzbeck <julio@techfuel.net> - 2013-12-01 17:01 -0800
csiph-web