In this program that I wrote will ask the user to give a string which contains a digits and then the program will count the number of digits in a giving string or sentence using Python programming language. I am using Pycharm as my text editor in writing this program. I hope you will learn something in this sample program.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Program Listing

# digits.py
# Jake Rodriguez Pomperada, MAED-IT, MIT
# jakerpomperada.com and jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# Bacolod City, Negros Occidental
print()
print("\tCount Digits in Python")
print()
val_str = input('Give a String : ')

count = 0
for char in val_str:
    if char.isdigit():
        count += 1
print()
print(f"Number of Digits:  {count}")
print()
print("\tEnd of Program")
print()

Leave a Reply

Your email address will not be published.