Get the latest tech news

Anatomy of a Python Loop


Learn Python loops the fun way by rolling dice, casting fireballs, and finally understanding what continue really does.

Last time, when we built our little dice-rolling function, we learned how to package up logic into reusable blocks. Some things I’ve learned from writing real production code (and yes, they apply even if you’re not programming fireballs): Whether you’re rolling 3d6, spamming fireballs, or retrying API calls in a backend service, the same principle applies: loop until you get what you need.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Anatomy

Anatomy

Photo of Python Loop

Python Loop

Related news:

News photo

The Big OOPs: Anatomy of a Thirty-Five Year Mistake

News photo

Anatomy of a $70M Auction Flop

News photo

Anatomy of a 'zombie' volcano: Investigating the cause of unrest inside Uturuncu