Skip to main content

Resilient Mean

Challenge on lesson: Checkpoint: Functions + Errors

Write mean(texts) that receives a list of strings. Convert each to a number; strings that cannot convert are skipped. Return the mean of the converted values as a float. If NOTHING converts, raise ValueError with the word 'empty' in the message. Print mean(values) for values = ["10", "x", "20", "", "30"] — one line, formatted :.2f.

Difficulty: beginner

Back to lesson: Checkpoint: Functions + Errors