I'm doing some Kaggle exercises and the question is asking me to "In the cell below, define a function called sign which takes a numerical argument and returns -1 if it's negative, 1 if it's positive, and 0 if it's 0". This was my function:
def sign(x):
if x < 0:
print('-1')
elif x > 0:
print('1')
else:
print('0')
I tested on VS Code but Kaggle saying it's "incorrect". The proper solution it's the following:
def sign(x):
if x > 0:
return 1
elif x < 0:
return -1
else:
return 0
I would like to know what's the real difference between my function and Kaggle's? Cheers