D
10
c/coding-for-beginnersmiles948miles9481mo agoProlific Poster

TIL my function needs a return to actually return something

I wrote a Python function that did nothing. Forgot the return line. Now it works as intended.
3 comments

Log in to join the discussion

Log In
3 Comments
river_scott
Right, "happens to all of us" is putting it nicely, @henry_campbell15. I've stared at a function for way too long, totally sure my logic was perfect, only to realize it was just a fancy way to do nothing. It's like packing a lunchbox but forgetting to put any food in it. The linter tip is solid, but sometimes you just have to learn by having your code give you the silent treatment.
10
henry_campbell15
Yeah, forgetting the return line happens to all of us.
-1
haydenc10
haydenc101mo ago
Setting up a linter caught it for me right away. Saved a bunch of headaches down the line.
8