python - Why do I get None as a result -
i have following script:
import math scores = [3.0,1.0,0.1] sum = 0 i=0 j=0 s in scores: sum = sum + math.exp(scores[i]) i=i+1 def myfunction(x): math.exp(x)/sum s2 in scores: print(myfunction(scores[j])) j=j+1
but, output is:
none none none
why that? how can retrieve correct values?
thanks.
you forgot return.
def myfunction(x): return math.exp(x)/sum
Comments
Post a Comment