I didn't yet find your problem. Using the interactive mode, I test your code in,
a) Python 2.6.3 and 3.1.1 (Debian Squeeze environment -system installed)
b) Python 2.6.2 (Ubuntu Jaunty 9.04 -working directly inside a Live CD session)
And no problem occurs... further than... in interactive mode you could break the "print" statement from the previous code unless you know the way to join the "if...elif...else" structure with it (I don't).
Although, note that this runs,
To continue checking you could try to do what I make in b)... and tell us.