+ 4
Why error??
''''A program that read a line from keyboard and convert the first letter of of each word into uppercase. like we have entered a line-- this is a high level language the output should come like-- This Is A High Level Language''' s=input("enter string") l=list(s) p=" " for i in l: for x in range (len(l)): if (x==0): p=p+i[0].upper() elif(i.isspace()): p=p+i[x+1].upper() print(s) print(p)
7 Answers
+ 3
Please tell me somebody
+ 3
s = input()
p = ''
for x in range(len(s)-1):
if x==0:
p=p+s[0].upper() + s[1]
elif(s[x].isspace()):
p=p+s[x+1].upper()
else:
p += s[x+1]
print(p)
+ 3
But what is the error in my code
+ 3
I m not getting
+ 1
You are converting str to list.
Use split function over there.
The list will be of single characters and in your code the first character changes to upper case. But your list contains all the characters as first characters. IndexBoundError because second for loop should have length of x and not l.