[Tutor] Converting integers into digit sum (Python 3.3.0)
Dave Angel
davea at davea.name
Mon Dec 9 18:38:28 CET 2013
On Mon, 09 Dec 2013 17:00:49 +0100, spir <denis.spir at gmail.com> wrote:
> On 12/09/2013 03:49 PM, Alan Gauld wrote:
> > On 09/12/13 13:48, spir wrote:
> >> On 12/09/2013 02:29 PM, Wolfgang Maier wrote:
> >> You are right in a sense, but this is what int() does, isn't it?
> > No. int() can be done in several ways but usually it's based on
taking the
> > character code and adding/subtracting some base value. (or uses a
lookup table).
> > But to get the individual characters for conversion
> > it will loop over a string so in that respect its similar to the
string based
> > approaches. But the OP didn't start with a string, he started
with an int.
It's str() which is similar, not int ()
--
DaveA
More information about the Tutor
mailing list