Write a program to input a number and
count the number of digits. The program
further check whether it contains odd
number of digit or even.
Answers
Answered by
1
n = int(input("number: "))
l = len(str(n))
print(f"no of digits: {l}")
if l % 2 == 0:
print("digits are even")
else:
print("digits are odd")
Answered by
1
Question:-
➡ Write a program to input a number and count the number of digits. The program further checks whether it contains off number of digit of even.
Program:-
This is written in Python. Its the easiest approach.
n=int(input("Enter the number: "))
x=len(str(n))
print("Number of digits: ",x)
if x%2==0:
print("Even number of digits.")
else:
print("Odd number of digits.")
Similar questions
Science,
3 months ago
India Languages,
3 months ago
Math,
3 months ago
India Languages,
6 months ago