e=raw_input('enter number') should be e=int(raw_input('enter number')) Unlike input(), raw_input() simply returns the input as a string, irrespective of what the input is. Since range(12) consists of the integers 0-11 inclusive but e is not an integer, e will never be in range(12). Thus e needs to be converted into an integer. Fortunately, there is a built-in function for that: int().