Given a string that contains both upper and lower case characters in it. The task is to count number of upper and lower case characters in it without using in-built functions.
Counting the upper and lower case characters of a string can be easily done using
islower() functions, refer this. But doing the same without help of any inbuilt function is quite exciting. Let’s see how this can be done :
Input : Introduction to Python Output : Lower Case characters : 18 Upper case characters : 2 Input : Welcome to GeeksforGeeks Output : Lower Case characters : 19 Upper case characters: 3
Below is the implementation of above idea :
('Lower case characters = 27', 'Upper case characters = 3')
- Python regex to find sequences of one upper case letter followed by lower case letters
- Python | Pandas Series.str.lower(), upper() and title()
- isupper(), islower(), lower(), upper() in Python and their applications
- Python String Methods | Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title)
- Python program to convert camel case string to snake case
- Lower and Upper Bound Theory
- Python | Toggle characters in words having same case
- Inbuilt Data Structures in Python
- Python | Permutation of a given string using inbuilt function
- Python | Count the Number of matching characters in a pair of string
- Python program to check if a string contains all unique characters
- Mathematical Functions in Python | Set 3 (Trigonometric and Angular Functions)
- Mathematical Functions in Python | Set 4 (Special Functions and Constants)
- Mathematical Functions in Python | Set 2 (Logarithmic and Power Functions)
- Python | String upper()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.