0
Why do integers not have a len()?
6 Answers
+ 4
Having a len() doesn't make too much sense, the len() function is usually for collections such as lists and sets because thereâs multiple elements, if you want to count the number of digits in a number you could use a while loop like so...
https://code.sololearn.com/c8hj9POITmwY/?ref=app
+ 1
Bobur Ochilov I updated the answer, I would put that code in a reusable function
+ 1
Bobur Ochilov simple.
len(str(1253))
or
num = 2927
num_of_digits = 0
while num :
num //= 10
num_of_digits += 1
print(num_of_digits)
0
And how can I find the number of digits in an integer?
0
Yeeah!!! Of course!
0
Thank you!