7. Write a python program to generate a function to accept an input string therefore count the number of lowercase and uppercase respectively.
The output is:
input string = 'Welcome to learn Python on Freelearningpoints website'
Expected Answer:
The initial string is: Welcome to learn Python on Freelearningpoints website
The number of uppercase characters is: 3
The number of lowercase Characters is: 44
Sample Answer:
def check_string(string): result={"UPPER_CASE":0, "LOWER_CASE":0} for i in string: if i.isupper(): result["UPPER_CASE"]+=1 elif i.islower(): result["LOWER_CASE"]+=1 else: pass print ("The initial string is: ", string) print ("The number of uppercase characters is: ", result["UPPER_CASE"]) print ("The number of lowercase Characters is: ", result["LOWER_CASE"]) check_string('Welcome to learn Python on Freelearningpoints website')
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)