Skip to main content

Resilient Mean

Challenge on lesson: Checkpoint: Functions + Errors

CHALLENGE
Difficulty: beginner+25 XP

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.

Back to lesson: Checkpoint: Functions + Errors