From the course: Python Data Analysis

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Finding anagrams

Finding anagrams - Python Tutorial

From the course: Python Data Analysis

Start my 1-month free trial

Finding anagrams

- [Instructor] We pick up our exercise where we left it in the last video. We have made a sorted list of lowercase words. lets load it up. Now, remember our strategy of comparing signatures. Those are the sorted lists of the component letters of each word. We need a function to make them. Taking the string N again as an example, let's see what happens if we sort it. Which we do with the built-in sorted. Indeed, we get a sorted list of the letters, which is already the signature. We can use it to verify say that Elvis is an anagram of lives, but not of sings. For convenience, we will collate the list of characters back into a single signature to string. The way this is achieved in Python looks a little strange, since we need to call the method join on a string that specifies the connector so to speak of the join. If it's a dash, we get a-a-n-o-r. So the connector we really want is the empty string. We're ready to make a…

Contents