Write a program that takes a string with multiple words and then capitalizes the first letter of each word and forms a new string out of it.
Answers
Answered by
33
- string = input("Enter a string:")
- length = len(string)
- a = 0
- end = length
- string2='' #empty string
- while a < length :
- if a == 0:
- string2 += string[0].upper()
- a += 1
- elif (string[a] =='' and string[a+1] !=''):
- string2 += sting[a]
- string1 += string[a+1].upper()
- a += 2
- else :
- string2 += string[a]
- a += 1
- print("Original String:", string)
- print("Capitalized words String", string2)
Answered by
12
string = input("Enter a string:")
length = len(string)
a = 0
end = length
string2='' #empty string
while a < length :
if a == 0:
string2 += string[0].upper()
a += 1
elif (string[a] =='' and string[a+1] !=''):
string2 += sting[a]
string1 += string[a+1].upper()
a += 2
else :
string2 += string[a]
a += 1
print("Original String:", string)
print("Capitalized words String", string2)
Read more on Brainly.in - https://brainly.in/question/9752907#readmore
Similar questions
https://brainly.in/question/9753192
also