0
Why "None" is also getting printed everytime ?
# This code is to check whether a number is prime or not ? def is_num_prime(x) : for i in range(2,x) : d = x%i if d == 0 : print('num is not prime') break else : print('num is prime') print(is_num_prime(13))
2 Respuestas
+ 2
If your function does not have a return statement, it returns None by default. This is the same case. What you are actually doing is passing the return value of is_num_prime to print, which is None. So None is printed. Change
print(is_num_prime(13))
to
is_num_prime(13)
+ 1
I got it.
Thanks XXX