1. Learn
  2. /
  3. Courses
  4. /
  5. Designing Agentic Systems with LangChain

Connected

Exercise

Build a tool with Python code

Now that your chatbot has the historical events and Wikipedia tools at its disposal, the school administration would also like you to add a grammar tool for the English curriculum. They've asked you to build a palindrome-checker that determines if an input phrase or word reads the same even when it is typed in reverse. The students should be able to use this tool to test different types of input strings to check if they are palindromes, such as "level" or "never odd or even", which both read the same when typed backwards.

Instructions

100 XP
  • Specify the input type for the tool as a string.
  • Convert the characters to lowercase using .lower(), removing any non-alphanumeric characters using .isalnum().
  • To determine if the text is a palindrome, check if the cleaned text matches its reversed version.
  • Complete the placeholders of the else statement with the original input to return the appropriate message for non-palindromes.