[Python] Count number of digits using for loop in Python

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I want to count number of digits of any digits number without converting the number to string and also using for loop. Can someone suggest how to do this.

    num = int(input("Enter any number : "))
    temp = num
    count = 0
    for i in str(temp):
    temp = temp // 10
    count += 1
    print(count)

    Continue reading...

Compartilhe esta Página