Table of Contents
Introduction
Given a string having no space in between the words and the starting letter of each word is capital.
Program
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:] output.append(i) print (' '.join(output)) ip_str = input("Enter the string: ") check_str(ip_str)
Output
Explanation
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.
0 Comments