From the course: Python Data Analysis
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Finding anagrams - Python Tutorial
From the course: Python Data Analysis
Finding anagrams
- [Narrator] We pick up our project where we left it In the last video. We have made a sorted list of lowercase words. Now remember our strategy of comparing signatures. A signature is the sorted list of the component letters. We need a function to make signatures. Taking again, the string aaron as an example, let's see what happens if we sort it, which we can do with a built-in sorted. We get a sorted list of the letters. We can use this as a signature to verify, say that Elvis lives. Or at least it lives, as anagram of Elvis. Unfortunately, David Bowie does not. For convenience, we will collate the list of characters back into a single signature string. The way this is achieved in Python looks a little strange. Since we need to call a method join on the string that specifies the connector. The connector that we want is really the empty string. (keyboard clatters) Finally, we make a function that performs this operation in general, and not just on aaron. Our strategy is based on…