'Python function prints a none value that I have no idea about it's origin

I have created a function here which prints if a number is prime or not . At the bottom of the image, I tried to print all the numbers in the console to show how many of them are prime numbers. Though all of the number from 2 to 19 showed in the console ,some extra none value attached to every single one of them . I have no clue why these none values appeared with every single number. Can anyone help with that? ( I am using sublime text)

enter image description here



Solution 1:[1]

Your python function will return None if it doesn't end with a return statement, and that's why at the end of every iteration in your for loop, it prints 'None' when it's done running the codes within the prime_numb function. You can fix it by returning a value.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marshal moses