Every task here is a small function of the kind analysts keep in a helpers file: cleaning a phone number, parsing a price, splitting a list into chunks.
Each function is checked on the calls in the prompt and on hidden ones. The hidden calls are the edge cases: empty input, a value exactly on a boundary, an empty middle name, text that isn't a number. Before you run the cell, ask yourself what the strangest valid input would be, and what your function returns for it.
Return values; don't print them. And when a function should refuse bad input, raise the error the prompt names.