In this post we will write a program that reads a line and print its statistics like:
Number of Lowercase Letters
Number of Uppercase Letters
Number of Alphabets
Number of digits

So let’s write the program

line = input("Enter a string/line/sentence: ")
lowercharcount = uppercharcount = 0
alphacount = digitcount = 0
for a in line:
  if a.islower():
    lowercharcount += 1
  elif a.isupper():
    uppercharcount += 1
  elif a.isdigit():
    digitcount += 1
  if a.isalpha():
      alphacount += 1
print("Number of Lowercase letters :",lowercharcount)      
print("Number of Uppercase letters :",uppercharcount)      
print("Number of Digits :", digitcount)      
print("Number of Alphabets :", alphacount)      


In the above output,you can see the line is Hello. It’s 4pm and it’s giving the statistics as how many lowercase/uppercase characters in the input line and also how many digit/alphabet the line contain.

I hope you will like this post. Happy Blogging!!