Program to add space between the words starting with capital letters


Given a string having no space in between the words and the starting letter of each word is capital.

add space between the words


import re  
def check_str(ip_str):  
    ele = re.findall('[A-Z][a-z]*', ip_str)  
    output = []  
    for i in ele:  
        i = chr( ord (i[0]) + 32) + i[1:]  
    print (' '.join(output)) 
ip_str = input("Enter the string: ")


add space between the words Output


In the above python code, we have used re.findall() function to extract the words starting with a capital letter from the given string and transformed each word to lower case. At last, we joined the words with space.


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.