+ 1

Help with python code.

The code will correct the punctuations. a =input("Enter your essay: ") s= a.split () r = len(s) for i in range(r): print (s[i]) if(s[i] == "i"): s[i]= s[i].replace ("i","I") print (s) s ="".join(s) s = list(s) r = len(s) for i in range(r): if (s[i] == "."): s[i+1]= s[i+1].upper() print (s) #input = i am an idiot. but i am not a Bad. #expected output = I am a idiot. But I am not bad.

17th Feb 2022, 10:48 AM
Nisha
3 odpowiedzi
+ 10
sentence=input("Enter your essay:\n") s= sentence.lower().split() r = len(s) for i in range(r): if(s[i] == "i"): s[i]= s[i].replace("i","I") s =" ".join(s) s = list(s.split()) r = len(s) for i in range(r-1): if ("." in s[i]): s[i+1] = s[i+1].capitalize() print(" ".join(s))
17th Feb 2022, 3:39 PM
Vaibhav
Vaibhav - avatar
0
sentence=input("Enter your essay: ") s= sentence .split () r = len(s) for i in range(r): if(s[i] == "i"): s[i]= s[i].replace ("i","I") s ="".join(s) s = list(s) r = len(s) for i in range(r): if (s[i] == "."): s[i+1]= s[i+1].upper() print (s) #input = i am an idiot. but i am not a Bad. #expected output = I am a idiot. But I am not bad. This one
17th Feb 2022, 11:12 AM
Nisha
0
sentence=input("Enter your essay:\n") s= sentence.lower().split() r = len(s) for i in range(r): if(s[i] == "i"): s[i]= s[i].replace("i","I") s =" ".join(s) s = list(s.split()) r = len(s) for i in range(r-1): if ("." in s[i]): s[i+1] = s[i+1].capitalize() print(" ".join(s)) # input : # i am an idiot. but i am not a Bad. # output : # I am a idiot. But I am not bad. #it can be shorten # capitalize() function capitalize first letter only.. # reply if anything not understand!! #hope it helps..
17th Feb 2022, 3:02 PM
Jayakrishna 🇮🇳