DEV Community

sheema
sheema

Posted on

Day 6: Functions, While Loops, and the Reeborg Maze ๐Ÿค–๐Ÿ

I just wrapped up Day 6 of my Python journey! Today was all about moving parts and automated navigation. After pushing through a tough logic wall yesterday, today felt a lot more rewarding, smooth, and honestlyโ€”just a ton of fun!

๐Ÿš€ What I Learned Today

  • Indentation Rules: Diving deep into how Python uses empty whitespace to group blocks of code together, and why a single wrong space ruins the flow.
  • Defining & Calling Functions: Learning how to bundle blocks of code into a single custom command (like def turn_right():) so I don't have to keep writing the same steps over and over.
  • While Loops: Moving away from set lists and mastering loops that run continuously based on a shifting condition. It's the ultimate tool for handling unpredictable scenarios!

๐Ÿ› ๏ธ The Projects: Reeborg's World
Todayโ€™s entire workspace was inside Reeborg's World, a digital grid where you write Python code to guide a tiny robot through puzzles.

  • Hurdles 1 to 3: I started by teaching Reeborg how to jump fixed walls. This was a perfect playground for combining my new custom functions with simple loops.
  • Hurdle 4: The real step up. The hurdles suddenly changed to completely random heights and positions. Instead of hardcoding the movements, I had to use while loops alongside dynamic checks like front_is_clear() and wall_in_front() to make Reeborg smart enough to adapt on the fly.
  • The Maze Game: The "Boss Fight" of Day 6! I had to program Reeborg to find the exit of a completely randomized maze from a random starting point. By using the "right-hand rule" logic inside a continuous while loop, I watched the robot smoothly solve its way out of every layout configuration.

๐ŸŽฎ๐Ÿง— The Fun Factor
Unlike yesterday's password generator where I felt like hitting a wall, today was a complete blast. Seeing the logic translate instantly into visual movements on the screen made everything click without the heavy frustration.

It was a great reminder that coding isn't always an exhausting uphill battle. Sometimes, when you get the functions and loops to cooperate, watching your automated script flawlessly conquer a game feels like pure magic!

python #codingjourney #100daysofcode #learningtocode #programming

Top comments (0)