Find Uppercase Letter in String

In this lesson, you will learn how to find the uppercase letter in a string using both an iterative and recursive approach in Python.

We'll cover the following

In this lesson, given a string, we develop an algorithm to return the first occurring uppercase letter. We will solve this problem using an iterative and recursive approach:

For instance, for the strings:

str_1 = "lucidProgramming"
str_2 = "LucidProgramming"
str_3 = "lucidprogramming"

The algorithm should return P L, and output a message indicating that no capital letter was found for str_1, str_2, and str_3, respectively.

Iterative Approach

Let’s have a look at the code in Python, which uses the iterative approach:

Get hands-on with 1200+ tech skills courses.