Header Ads

Python - WAP to Count the Digits in a Number in Python - 11


This is a Python Code to Count the Digits in any given Number using Python 3.5

Source Code:
#!/usr/bin/python3

while True:

    num = int(input("Enter a Number : "))
    count = 0

    # Counting the Total Digits
    while (num > 0 ):
        count += 1
        num = num // 10

    # Printing the digits.
    print ("The Number of Digits is :", count)

    # Continue block.
    print (" - Codegig.org")
    if (input("To Continue ['y'] : ") == 'y' ):
        continue
    else:
        break

Program Output:




....

No comments