Write a program to calculate and print number of letters and digits in a string


Topic: Write a program to calculate and print number of letters and digits in a string

Solution

str1 = "python1234"
  
total_digits = 0
total_letters = 0
  
for s in str1: 
  
    if s.isnumeric(): 
        total_digits += 1
    else: 
        total_letters += 1
  
print("Total letters found : ", total_letters) 
print("Total digits found : ", total_digits) 



List all Python Programs