Hi again guys, in the exercise of the title we have that:
Your task in this mission is to truncate a sentence to a length that does not exceed a given number of characters.
_
_If the given sentence already is short enough, you don't have to do anything to it. But if it needs to be truncated, the omission must be indicated by concatenating an ellipsis ("...") to the end of the shortened sentence.
_
_The shortened sentence can contain complete words and spaces.
It must neither contain truncated words nor trailing spaces.
The ellipsis has been taken into account for the allowed number of characters, so it does not count against the given length.
First assert its:
assert cutsentence("Hi my name is Alex", 8) == "Hi my..."_
In the assert above we're good. We have 8 as max lenght and the number of characters matches to 8.
But, why this assert has to be "Hi...":
assert cutsentence("Hi my name is Alex", 4) == "Hi..."_
Since the "..." are contemplated in the length, if you check, in the assert test we have a length == 5, not 4.
Is the assert wrong or im missleading something? Im stuck here and cant keep coding (because i think the test is bad) and i dont wanna make a dirty bypass to it.
Thank you
Created at: 2022/11/01 17:21; Updated at: 2022/11/02 13:15
The question is resolved.