Tech Study

Write a Python program that accepts a string and calculate the number of digits and letters

Introduction

Write a Python program that accepts a string and calculate the number of digits and letters. I have used python 3.7 compiler for debugging purpose.

str = input("Input a string: ")
d=l=0
for c in str:
    if c.isdigit():
        d=d+1
    elif c.isalpha():
        l=l+1
    else:
        pass
print("Letters", l)
print("Digits", d)

Result

Write a Python program that accepts a string and calculate the number of digits and letters
Write a Python program that accepts a string and calculate the number of digits and letters

TaggedWrite a Python program that accepts a string and calculate the number of digits and letters

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more