Some quick things that caught my attention: * Your code does not handle exceptions, what if the user inputs "xyz" and the program raises a ValueError? * Some PEP-8 things: 1. A comma ```,``` should be followed by a [space], for readability; 2. A modulo operator, as well as other mathematical operators, should be preceded by and followed by a [space]; 3. A ```range()``` call (or any other function call), should **not** be followed by a [space] before the first argument; * Use ```i += 1``` instead of ```i = i + 1```; * Calling ```print``` without ```" "``` will also print -nothing-. Rewritten ------------- while True: x = raw_input("Input a number: ") try: x = int(x) break except ValueError: print("Input must be a number!") for i in range(x): a = map(int, raw_input().split()) if a[0] == 1: a[0] = 2 for num in range(a[0], a[1]+1): if num == 2: print num for j in range(2, num): if num % j == 0: break elif j == num - 1: print num print i += 1