zlacker

[return to "My favorite programming problem to teach: Digit length (2019)"]
1. nicbou+I93[view] [source] 2024-06-06 05:39:07
>>equili+(OP)
Wouldn't len(str(num)) be adequate here? This is a quite literal translation of what the code should be doing: measuring the length of the text representation of a number. The mathematical approach seems a little convoluted, although it serves the purpose of teaching a lesson.
◧◩
2. _xnmw+ac3[view] [source] 2024-06-06 06:07:32
>>nicbou+I93
Len() and str() are a loop under the hood.
[go to top]