1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Intermediate Python for Developers

Connected

Bài tập

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.

Hướng dẫn

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.