In Python 2, input
takes a string from the user, and evaluates it. So when you enter "S", it tries to evaluate it, looking for the name "S", which doesn't exist.
Use raw_input
instead of input
.
Yes, this was crazy. It's fixed in Python 3, where raw_input
is now named input
.