I’m really into Python this summer, and thought I might share some of my work. I started off with a (simple enough) web application to connect to MySQL on Fedora 12, trying to make a cricket statistics site. It went off pretty well, but I got pretty bored and went off to do an Anagram generator. This morning I started off, with a basic tool to check if two strings are anagrams of one another.
The flow I thought of was:
1. Remove spaces from the strings, and sort them in ascending order.
2. Compare the sorted strings to see if they are equal. The two steps can be done in a single line.
return sorted(list(in1)) == sorted(list(in2))
This will show if the two strings are anagrams of each other.
I need to create a dictionary of words, and then think of a way to get the major anagram generation part going. I hope to complete that over the weekend. I also hope to check my code on Python 2 and 3, using Fedora 13’s parallel installable stacks.