In this program, we will take a string as input and insert space before every capital letter appears in a given word.
Steps to solve the program
- Take a string as input and create an empty string.
- Use for loop to iterate over every character of the string.
- Add each character to the empty string.
- If a character is Capital letter then add space first then the character.
- Print the output.
#Input string
str1 = "SqaTools pyThon"
result = ""
for char in str1:
if char.isupper():
result=result+" "+char
else:
result=result+char
#Printing output
print(result)
Output :
Sqa Tools py Thon