Find the words in a string
Problem to split the words in given string.The word first letter should be Capital and other characters are lowercase.
Example-1:
Input : s = "MyCrazyCoding" Output : ['My', 'Crazy', 'Coding']
Example-2:
Input : s = "HelloWorld" Output : ['Hello', 'World']
Solution
s = "MyCrazyCoding" s = s + " " d = "" for i in range(1,len(s)): if(s[i-1].islower() and s[i].isupper()): d += s[i-1] d += " " else: d += s[i-1] d = d.strip() d = d.split() print(d)
Output
['My', 'Crazy', 'Coding']