If I don't know what errors you get, I can't help you, although I do have a tip:
don't use input(), but use raw_input(), and then convert it to an int, like this:
int(raw_input()). Take a look here, part 4.12. It's a great book, btw.

Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems. - Jamie Zawinski, in comp.lang.emacs