It's basically correct but you need to convert the raw_input to integer. c=0 d=int(raw_input("input number limit: ")) while 1: c = c + 1 if c == d: break print c