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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -