mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 05:21:09 +00:00
7a14285cb6
* Added Lstm example for stock predection * Changes after review * changes after build failed * Add Kiera’s to requirements.txt * requirements.txt: Add keras and tensorflow * psf/black * haris corner detection * fixup! Format Python code with psf/black push * changes after review * changes after review * fixup! Format Python code with psf/black push Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
19 lines
311 B
Python
19 lines
311 B
Python
def num_digits(n: int) -> int:
|
|
"""
|
|
Find the number of digits in a number.
|
|
|
|
>>> num_digits(12345)
|
|
5
|
|
>>> num_digits(123)
|
|
3
|
|
"""
|
|
digits = 0
|
|
while n > 0:
|
|
n = n // 10
|
|
digits += 1
|
|
return digits
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(num_digits(12345)) # ===> 5
|