tutorial
- Faq
- Faq
- Python Program - Add Two Matrices
- Python Program - Add Two Numbers
- Python Program - Sort Words in Alphabetic Order
- Python Program - Check If Two Strings are Anagram
- Python Program - Append to a File
- Python Program - Calculate the Area of a Triangle
- Python Program - Find Armstrong Number in an Interval
- Python Program - Check Armstrong Number
- Python Program - Find ASCII Value of Character
- Python Program - Convert Bytes to a String
- Python Program - Make a Simple Calculator
- Python Program - Capitalize the First Character of a String
- Python Program - Catch Multiple Exceptions in One Line
- Python Program - Convert Celsius To Fahrenheit
- Python Program - Check If a List is Empty
- Python Program - Check the File Size
- Python Program - Check If a String Is a Number (Float)
- Python Program - Get the Class Name of an Instance
- Python Program - Print Colored Text to the Terminal
- Python Program - Concatenate Two Lists
- Python Program - Convert Decimal to Binary, Octal and Hexadecimal
- Python Program - Copy a File
- Python Program - Count the Number of Each Vowel
- Python Program - Create a Countdown Timer
- Python Program - Safely Create a Nested Directory
- Python Program - Get the Full Path of the Current Working Directory
- Python Program - Convert Decimal to Binary Using Recursion
- Python Program - Delete an Element From a Dictionary
- Python Program - Display Calendar
- Python Program - Measure the Elapsed Time in Python
- Python Program - Extract Extension From the File Name
- Python Program - Find the Factors of a Number
- Python Program - Find Factorial of Number Using Recursion
- Python Program - Find the Factorial of a Number
- Python Program - Display Fibonacci Sequence Using Recursion
- Python Program - Print the Fibonacci sequence
- Python Program - Get File Creation and Modification Date
- Python Program - Get the File Name From the File Path
- Python Program - Find All File with .txt Extension Present Inside a Directory
- Python Program - Flatten a Nested List
- Python Program - Find Hash of File
- Python Program - Find HCF or GCD
- Python Program - Print Hello world!
- Python Program - Access Index of a List Using for Loop
- Python Program - Iterate Over Dictionaries Using for Loop
- Python Program - Iterate Through Two Lists in Parallel
- Python Program - Check if a Key is Already Present in a Dictionary
- Python Program - Convert Kilometers to Miles
- Python Program - Find the Largest Among Three Numbers
- Python Program - Find LCM
- Python Program - Check Leap Year
- Python Program - Get Line Count of a File
- Python Program - Split a List Into Evenly Sized Chunks
- Python Program - Get the Last Element of the List
- Python Program - Slice Lists
- Python Program - Convert Two Lists Into a Dictionary
- Python Program - Merge Two Dictionaries
- Python Program - Create a Long Multiline String
- Python Program - Return Multiple Values From a Function
- Python Program - Display the multiplication Table
- Python Program - Multiply Two Matrices
- Python Program - Find Sum of Natural Numbers Using Recursion
- Python Program - Find Numbers Divisible by Another Number
- Python Program - Count the Number of Occurrence of a Character in String
- Python Program - Count the Number of Digits Present In a Number
- Python Program - Count the Occurrence of an Item in a List
- Python Program - Check if a Number is Odd or Even
- Python Program - Check Whether a String is Palindrome or Not
- Python Program - Compute all the Permutation of the String
- Python Program - Check if a Number is Positive, Negative or 0
- Python Program - Display Powers of 2 Using Anonymous Function
- Python Program - Compute the Power of a Number
- Python Program - Print all Prime Numbers in an Interval
- Python Program - Check Prime Number
- Python Program - Print Output Without a Newline
- Python Program - Create Pyramid Patterns
- Python Program - Solve Quadratic Equation
- Python Program - Randomly Select an Element From the List
- Python Program - Generate a Random Number
- Python Program - Read a File Line by Line Into a List
- Python Program - Remove Duplicate Element From a List
- Python Program - Remove Punctuations From a String
- Python Program - Represent enum
- Python Program - Find the Size (Resolution) of a Image
- Python Program - Reverse a Number
- Python Program - Illustrate Different Set Operations
- Python Program - Shuffle Deck of Cards
- Python Program - Sort a Dictionary by Value
- Python Program - Find the Square Root
- Python Program - Convert String to Datetime
- Python Program - Parse a String to a Float or Int
- Python Program - Get a Substring of a String
- Python Program - Find the Sum of Natural Numbers
- Python Program - Swap Two Variables
- Python Program - Transpose a Matrix
- Python Program - Trim Whitespace From a String
- Python - Differentiate Between type() and isinstance()
Python Program - Count the Number of Digits Present In a Number
You can count the number of digits present in a number using the following Python program:
refer to:editfigia.comnum = int(input("Enter a number: ")) count = 0 while num > 0: num = num // 10 count += 1 print("Number of digits:", count)
In this program, we first take an integer input from the user. We then initialize a variable count
to zero, which will store the count of digits in the number.
We then use a while
loop to keep dividing the number by 10 until it becomes zero. In each iteration, we increment the count
variable by 1.
Finally, we print the value of the count
variable, which gives us the number of digits present in the input number.