We also might want to look at only valid words in our data set. A word will be a valid word if all three of the followin
Posted: Mon May 02, 2022 11:40 am
We also might want to look at only valid words in our data set.
A word will be a valid word if all three of the following
conditions are true:
There is at most one punctuation
mark. If present, it must be at
the end of the word ("ab,", "cd!",
and "." are valid,
but "a!b" and "c.," are not valid).
NB: for this question, the 3rd condition will also apply to
apostrophes despite "valid" words containing them.
Write a function valid_words_mask(sentence) that takes
an input parameter sentence (type string) and returns the
tuple: (int, list[]), where:
*Assume that a punctuation mark is any character that is not an
alphanumeric (except for hyphens, which are handled separately as
per the instructions).
A word will be a valid word if all three of the following
conditions are true:
There is at most one punctuation
mark. If present, it must be at
the end of the word ("ab,", "cd!",
and "." are valid,
but "a!b" and "c.," are not valid).
NB: for this question, the 3rd condition will also apply to
apostrophes despite "valid" words containing them.
Write a function valid_words_mask(sentence) that takes
an input parameter sentence (type string) and returns the
tuple: (int, list[]), where:
*Assume that a punctuation mark is any character that is not an
alphanumeric (except for hyphens, which are handled separately as
per the instructions).