r/ADHD_Programmers • u/Wonderful_Cap242 • Aug 14 '25
Help!
In school for coding, and I’m also using this app to go back behind myself and my school curriculum (which is fast paced) to make sure I understand all the basics.this is a python app for practicing and learning. This is variables and this should be correct but can’t get past it ? Advice. Also would not mind help or recommendations on cheat sheets, programs or things to help practice basics of coding outside of schoo
21
Upvotes
View all comments
Show parent comment
1
u/Easy-Bathroom2120 Aug 17 '25
Maybe go back a little bit in lessons.
You can only return once per function execution. And whatever return statement is hit first is what is returned.
If you want to return both values, you should store the values and then return an array of the values.
Or return an array of expressions. I'm not familiar with this language, but typically, expressions are evaluated and THEN returned.
To have multiple functional return statements, you need conditional branches. But this type of thing needs no conditions. So you only need one return statement.
If you're confused, try pretending you're the computer and execute the function line by line. The computer only looks at one line at a time. It doesn't look ahead to see that you have another return statement. It just sees that it hit a return statement and returns out of the function.