+ 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.
3 Answers
+ 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))
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
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..