Q:

Python - identifying if integer is a prime or not? Output prints both a prime and not a prime

#Enter an integer
num = int(input("Enter a number: "))

#Prime number is a positive integer that is evenly divisible by 1 and itself
#Zero and one shouldn't be prime numbers

#Use for loop in the range of 2 as the first prime to any integer num
#If else statements: If integer num is divisible by any integer between
#2 and itself the integer num isn't a prime number
#or else the integer is a prime number

if num < 2:
    print(num, "isn't a prime number")

for x in range(2, num):
    if num % x == 0:
        print(num, "isn't a prime number")
        break
else:
    print(num, "is a prime number")

Observations -
The output I am getting when I enter the integer 0 and integer 1      individually, is:
0 isn't a prime number 
0 is a prim number
1 isn't a prime number
1 is a prime number

Keeping in mind this is with the if statement before the for loop. With it the entire program outputs every other integer correct. But still for integer 0 and 1:
It outputs:
0 is a prime number
1 is a prime number

A:

You don't return when checking for num < 2. You could change to:
if num < 2:
    print(num, "isn't a prime number")
    return

assuming that you are in a function. Otherwise you could use else:
if num < 2:
    print(num, "isn't a prime number")
else:
    for x in range(2, num):
        if num % x == 0:
            print(num, "isn't a prime number")
            break
    else:
        print(num, "is a prime number")

