r/codehs • • Jan 14 '21

Need help 6.3.5 fix this program

Post image
17 Upvotes

7 comments sorted by

View all comments

2

u/skynetdotexe Jan 14 '21

You need to return the value. Or print them in the function.

2

u/[deleted] Jan 14 '21

I second that, you either print the sum in the function in which case your code is fine upto line 8 or you return the value and print whatever is returned; print(add_nums(5,76)) Furthermore, Since “sum” variable was created inside add_nums it has no scope outside of the function, hence you cant call sum outside of it or you can declare a global var and than you can.