1. 学ぶ
  2. /
  3. コース
  4. /
  5. Intermediate Python for Developers

Connected

演習

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.

指示

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.