I'm new to functions and cannot figure out why this returns 'None' Essentially the State is a number, so this should input the state and spit out the population. I'll change the format to be more vague and helpful for all once I understand better. Thanks!
def ca_pov(state, spending=0):
state = person[person.state==state].copy(deep=True)
total_population = state.weight.sum()
return
total_population
print(ca_pov(11))
asked Jul 12, 2020 at 13:53
user13747020
1 Answer 1
the total_population was not returned. You have to write the return keyword and the data you want to return next to it.
def ca_pov(state, spending=0):
state = person[person.state==state].copy(deep=True)
total_population = state.weight.sum()
return total_population
print(ca_pov(11))
answered Jul 12, 2020 at 13:53
Aleksander Ikleiw
2,7152 gold badges11 silver badges29 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Aleksander Ikleiw
@Nate Go if this works for you please accept my question and upvote it :)
lang-py
return person[person.state==state].copy(deep=True).weight.sum()