• mistake in the exercise?


hi, i think there might be a mistake in "Correct Sentence" exercise. first, the two last assertions are missing from the code, i had to add them from the checking results('hi' , 'welcome to New York'). second thing is that the phrase "New York" does not go by the rules of the exercise, it did not said to recognize names.

The exercise:

" For the input of your function, you will be given one sentence. You have to return a corrected version, that starts with a capital letter and ends with a period (dot). Pay attention to the fact that not all of the fixes are necessary. If a sentence already ends with a period (dot), then adding another one will be a mistake. "

this is my failed try:

def correct_sentence(text: str) -> str:

    if text[-1]=='.':

        return "".join(text[0].upper()+text[1:].lower())

    return "".join(text[0].upper()+text[1:].lower()+'.')


print(correct_sentence("greetings, friends"))

# These "asserts" are used for self-checking

assert correct_sentence("greetings, friends") == "Greetings, friends."

assert correct_sentence("Greetings, friends") == "Greetings, friends."

assert correct_sentence("Greetings, friends.") == "Greetings, friends."

assert correct_sentence("greetings, friends.") == "Greetings, friends."

assert correct_sentence('hi') == 'Hi.'

assert correct_sentence('welcome to New York') == 'Welcome to New York.'

print("The mission is done! Click 'Check Solution' to earn rewards!")

i am enjoying your site,

Thank you.