Lara,
I've given you the solution!! What exactly were you expecting, a copy of all my code?
Where would be the fun in that? :-)
My intention was to point you in the direction of the answer and let you try to figure it out from there.
If you really need it I could extract part of the code for you and post it, but I've always preferred to help with code only when there is a specific need. Otherwise you won't learn anything. :-)
I figured I'd point you in the right area (note - exec() is your friend) and then you could have a crack at it. If you get stuck with a particular part of your code not working, I could help debug that. And then at the end of the day not only have you got a working solution to your problem, but you've extended your knowledge base.
-- Nick Gushlow