The problem set number 6 in cs50 requires to rebuild the Readability project from week 2 in Python
But there is a problem I haven't encountered first when writing the code in C
The programm uses for loop for each letter in input to check if its a period, exclamation point, or question mark which all indicate the end of a sentence
But the input that check50 throws at the program has multiple periods back to back each of which count as its own sentence
So the question is:
How can I improve this sentence counting function to only concider one of periods in case it encounters them back to back? Should I for example add a condition that sees next symbol in a for loop and if its also a period it just ignores it?
def countSentences(input):
counterS = 0
for symbol in input:
if symbol in ['.', '!', '?']:
counterS += 1
return counterS