In this example, let’s see how to count the number of uppercase characters in the string.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
str = input("Please input the string: ")
count = 0
for i in str:
if i.isupper():
count += 1
print("The number of uppercase characters is: ", count)
Output:
Please input the string: AbcDeF
The number of uppercase characters is: 3