Find Unique Words
Easy
Write a function unique_words(text) that takes a string of words separated by spaces and returns the count of unique words (case-insensitive), using a set.
Input
A string of space-separated words.
Output
An integer representing the number of unique words.
Example
Input
"the cat sat on the mat the cat ran"
Output
5
Lowercase the string, split on spaces, and convert to a set to remove duplicates.
10 XP on solve
Back to lesson
Your Solution
Output
Click "Run" to execute your code...
⏳ Loading Python runtime (first run may take a few seconds)...
Log in to submit your solution and earn XP.