how to get the length of a number
Stan Cook
sdcook55 at sbcglobal.net
Sun Jun 11 16:24:58 EDT 2006
Saketh wrote:
> Stan Cook wrote:
>> Can anyone tell me how to get the length of a number. I
>> know len(string) will get the length of a string, but it
>> doesn't like len(int). I seem to remember something like %s
>> string. I tried to set a variable = to %s int, but that
>> doesn't work. Is there a function I've forgotten about to
>> convert an integer to a string?
>>
>> Regards
>>
>> Stan
>
> Use str(int). Then use len(). For example, len(str(12345)) will give
> you 5.
>
Ahhhh! How could I have forgotten that. Boy is my face red :)
Thanks....
I'll try to make my next question a more intelligent one.
Regards,
Stan
More information about the Python-list
mailing list