Prime or not in Python

Python Program to find prime or not

Source code :

def prime(x):
    if x > 1:
        for i in range(2, x + 1):
            
            if x % i == 0 and i != x and i != 1:
                return False
        else:
            return True
    else:
        return False
        
print(prime(29))

Output :

True

Output :


                

Comments :