why does the following code returns none:
j = 22
def test(j):
    if j > 0:
        print('j>0')
    else:
        print('j<0')
Output:
j>0
None
why does the following code returns none:
j = 22
def test(j):
    if j > 0:
        print('j>0')
    else:
        print('j<0')
Output:
j>0
None
 
    
     
    
    A function in Python always has a return value, even if you do not use a return statement, defaulting to None
Because the test function doesn't return a value, it ends up returning the object None. that's why it ended up printing None Since you do not have a return value specified
you may not use print in your function, but return a string instead
def test(j):
    if j > 0:
        return 'j>0'
    else:
        return 'j<0'
then call it like this: print it when calling the function
print(test(22)) 
 
    
    