Why error?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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)

10th May 2019, 5:14 AM
SOUMYA
SOUMYA - avatar
5 ответов
+ 3
Please tell me somebody
10th May 2019, 5:24 AM
SOUMYA
SOUMYA - avatar
+ 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)
10th May 2019, 5:48 AM
Anna
Anna - avatar
+ 3
But what is the error in my code
10th May 2019, 5:48 AM
SOUMYA
SOUMYA - avatar
+ 3
I m not getting
10th May 2019, 5:53 AM
SOUMYA
SOUMYA - avatar
+ 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.
10th May 2019, 5:31 PM
Right Liar