189k views
3 votes
Tests that replace_punctuation() replaces 1 exclamation point and 2 semicolons in "we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!".

1 Answer

3 votes

Answer:

def replace_punctuation(input_str,exclamationCount =0,semicolonCount=0):

result=''

for i in input_str:

if i=='!':

i='.'

exclamationCount+=1

elif i==';':

i=','

semicolonCount+=1

result+=i

print('Punctuation replaced')

#displaying replaced values counts

print('exclamationCount:',exclamationCount)

print('semicolonCount:',semicolonCount)

return result

Step-by-step explanation:

User Korhner
by
4.2k points