PIXELBANKv9.1.0
Menu

Classify a text into one of three categories based on keyword matching:

  • sports: contains any of ["goal", "team", "player", "match", "score"]
  • tech: contains any of ["code", "software", "computer", "algorithm", "data"]
  • food: contains any of ["recipe", "cook", "ingredient", "meal", "dish"]

Check categories in the order: sports → tech → food. Return the first matching category. If no keywords match, return "other".

All matching is case-insensitive and checks if the keyword appears as a whole word in the text.

Input: A single line of text.

Example:

Input:
The team scored a goal
Output:
sports
Reasoning:

Step 1: Lowercase and split "the team scored a goal" → words: ["the", "team", "scored", "a", "goal"]

Step 2: Check sports keywords "team" matches → return "sports"

Constraints:

  • Case-insensitive word matching
  • Check sports first, then tech, then food
  • Return first matching category
  • If no match, return "other"
solution.py

Test Results

0/0
Run code to see test results.