To count number of digits in an integer (or) To count number of digits/letters using inbuilt method

 #To count number of digits in an integer

x = int(input("Enter a string"))

count = 0

while x  != 0:

    x //= 10

    count += 1

print("Number of digits are "+str(count))

'''

#To count number of digits/letters using inbuilt method

x = input("Enter a string")

print("Number of digits/letters are ",len(str(x)))

'''

Comments

Popular posts from this blog

Data Science Matplotlib Library Data Visualization, ASSIGNMENT - 6, GO_STP_8113