1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Developers

Connected

Exercise

Returning errors

Time to try out the other approach for error handling.

Revise the clean_text() function to intentionally produce an error if an incorrect data type is used.

Instructions

100 XP
  • Check whether the data type of the text argument is a string str.
  • Inside the else block, produce a TypeError() to prevent the script from running and return a descriptive message.