There are many different ways to test primality, but the loop you wrote can be concisely revised in Python:
def is_prime(a):
return all(a % i for i in xrange(2, a))
The variable is prime if all numbers between 2 and a (not inclusive) give a non-zero remainder when divided into a.
If you are a beginner and want to know more about Python, then do check out the below Python tutorial video that will help you in understanding the topic in a better way: