468,736 Members | 1,930 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,736 developers. It's quick & easy.

Finding the number of digits from a given number

440 256MB
Hi,

How to find the number of digits from a given number?.

For example
num = 23456

The number of digits are 5

num = 2311150

The number of digits are 7

-PSB
Apr 23 '07 #1
1 2617
ilikepython
844 Expert 512MB
Hi,

How to find the number of digits from a given number?.

For example
num = 23456

The number of digits are 5

num = 2311150

The number of digits are 7

-PSB
Well you can convert the number to a string:
Expand|Select|Wrap|Line Numbers
  1. num = 2311150
  2. num = str(num)
  3. print len(num)
  4. #prints 7
  5.  
There's probably a better way though.
Apr 23 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by lecichy | last post: by
1 post views Thread by Shreyas Kulkarni | last post: by
27 posts views Thread by Luke Wu | last post: by
19 posts views Thread by gk245 | last post: by
109 posts views Thread by jmcgill | last post: by
22 posts views Thread by jobo | last post: by
23 posts views Thread by Arnaud Delobelle | last post: by
13 posts views Thread by arnuld | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.