Python Program To Test String Starts With A Capital Letter

Python Program To Test String Starts With A Capital Letter

01. Example

Using isupper() function with For loop.

  1. Initialize String.
  2. Set a flag value False.
  3. Check with isupper() function for first element of string.
  4. If first element is capital then change flag value False to True.
  5. Print output.
string ="Zeroones python programs."
print("The input string : " + str(string))

flag = False
for element in string.split():
    if element[0].isupper():
        flag = True
        
# printing result
print("Paragraph First Letter Is Capital: " + str(flag))

Output:

The input string : Zeroones python programs.
Paragraph First Letter Is Capital: True

 

Leave a comment