
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to count upper and lower case characters without using inbuilt functions
In this article, we will learn about the solution and approach to solve the given problem statement.
Problem statement
Given a string input, we need to find the number of uppercase & lowercase characters in the given strings.
Here we will we checking ASCII value of each character by the help of built-in ord() function.
Here we have assigned two counters to 0 and we are traversing the input string and checking their ASCII values and incrementing their counter respectively.
Now let’s see the implementation below −
Example
def upperlower(string): upper = 0 lower = 0 for i in range(len(string)): # For lowercase if (ord(string[i]) >= 97 and ord(string[i]) <= 122): lower += 1 # For uppercase elif (ord(string[i]) >= 65 and ord(string[i]) <= 90): upper += 1 print('Lower case characters = %s' %lower, 'Upper case characters = %s' %upper) # Driver Code string = 'Tutorialspoint' upperlower(string)
Output
Lower case characters = 13 Upper case characters = 1
All variables and functions are declared in global scope as shown in the figure below.
Conclusion
In this article, we learned about the approach to count upper and lower case characters without using inbuilt functions.
- Related Articles
- Count upper and lower case characters without using inbuilt functions in Python program
- Java program to count upper and lower case characters in a given string
- C# program to count upper and lower case characters in a given string
- How to convert Lower case to Upper Case using C#?
- How to convert Upper case to Lower Case using C#?
- C program to convert upper case to lower and vice versa by using string concepts
- Convert vowels from upper to lower or lower to upper using C program
- MySQL Query to change lower case to upper case?
- How to return the first unique character without using inbuilt functions using C#?
- Python regex to find sequences of one upper case letter followed by lower case letters
- Program for converting Alternate characters of a string to Upper Case.\n
- How to return the index of first unique character without inbuilt functions using C#?
- Golang Program to Convert Char Type Variables to Int Using Inbuilt Functions
- Java Program to check whether the entered character a digit, white space, lower case or upper case character
- How to find the missing number and the repeated number in a sorted array without using any inbuilt functions using C#?

Advertisements