Blog
Part of 30 Days Back to Basics· 3/5

Day 2: Nothing Comes Back

2 July 20262 min readday-2week-1pythonfunctionsback-to-basics
Day 2: Nothing Comes Back

Day 2: Nothing Comes Back

Short day today. only a few hours, busy schedule, no big project. But short doesn't mean nothing happened. I made the same mistake three times in a row before it actually stuck.

What I actually built

Three functions: is_even(), fizzbuzz(), and a small calculator. The goal wasn't the functions themselves. it was learning the difference between a function that returns a value and one that just prints something and hands back nothing.

That sounds obvious written down. It was not obvious while I was writing it.

Where I got stuck

is_even() took three attempts. First I tried to jam an entire if/else block inside a single return(...): invalid syntax, Python can only return one expression, not a chain of statements. Second attempt, I wrote boole = print(True) thinking that would store True in the variable. It doesn't. print() always hands back None, no matter what you passed into it: its job is to display something on screen, not to give you a usable value back. Third attempt finally worked, and later I realized the whole function could just be return x % 2 == 0, no if/else needed at all: I'd built a small decision tree around a boolean that already existed on its own.

Then I hit the exact same trap again inside fizzbuzz(): return print("FizzBuzz"), before catching it myself.

And a third time inside the calculator's divide-by-zero branch, except that time I caught it without anyone flagging it. Same mistake, but the third time I saw it coming.

Separately, fizzbuzz() had its own bug: I checked if a & b: thinking that meant "both a and b are zero." It doesn't: that's bitwise AND on the actual numbers, not a combined true/false check. Fixed it by adding a dedicated n % 15 check instead of trying to be clever about combining the two.

What I understand now that I didn't this morning

A function that returns a value gives the caller something to work with. A function that only prints is a dead end: the value existed for one instant on screen and then it's gone. print() returning None isn't a bug, it's just not what I wanted, and I asked it to be something it was never built to be.

I also noticed how often an if/else is just decoration around a value that already exists. x % 2 == 0 already is True or False: wrapping it in a full conditional to hand back a variable called True or False doesn't add anything.

Carrying into tomorrow

String manipulation without shortcuts: reversing a string, counting vowels, checking for a palindrome, all done with a manual loop instead of slicing or built-in helpers. Last item on the Week 1 checklist.

In this series · 30 Days Back to Basics

  1. 01Day 0: 30 Days Back to Basics
  2. 02Day 1: Bricks Before Blueprints
  3. 03Day 2: Nothing Comes Back
  4. 04Day 3: Five Bugs to Reverse a String
  5. 05Day 4: A String Bug Passed Its Own Test For the Wrong Reason