The Art of Clean Code [Book Reviews]

On this page, I’ll collect selected reader feedback for my newest book πŸ“• “The Art of Clean Code” (Amazon, NoStarch). I’ll only share the feedback from readers who explicitly agreed to publish it here. πŸ‘‰ Want to Get Featured Here? Feel free to send in your feedback by replying to any of my emails. “Cannot … Read more

How to Stop a For Loop in Python

Python provides three ways to stop a for loop: The for loop ends naturally when all elements have been iterated over. After that, Python proceeds with the first statement after the loop construct. The keyword break terminates a loop immediately. The program proceeds with the first statement after the loop construct. The keyword continue terminates … Read more

The Math of Becoming a Millionaire in 13 Years

When I browse the web or social media, guides on how to become a millionaire pop up everywhere. If you read them, you’ll quickly find out that they’re filled with the same fluff. Let’s call it “slow-lane thinking” after DeMarco’s popular book. Most of those guides assume you have four decades of diligent savings left. … Read more

If-Then-Else in One Line Python

Quick answer: How to put a simple if-then-else statement in one line of Python code? To put an if-then-else statement in one line, use Python’s ternary operator x if c else y. This returns the result of expression x if the Boolean condition c evaluates to True. Otherwise, the ternary operator returns the alternative expression … Read more

Python One Line Ternary

The most basic ternary operator x if c else y consists of three operands x, c, and y. It is an expression with a return value. The ternary operator returns x if the Boolean expression c evaluates to True. Otherwise, if the expression c evaluates to False, the ternary operator returns the alternative y. Ternary … Read more

Python – How to Find the Longest Substring in Alphabetical Order?

Programming Challenge πŸ’¬ Challenge: Given a Python string. Find the longest substring for which holds that all of its characters are in alphabetical order so that the first character comes earlier in the alphabet than the second character, and so on. Here are three examples: You get the point. πŸ™‚ Next, I’ll show you three … Read more

How to Filter a Dictionary in Python? (… The Most Pythonic Way)

Problem: Given a dictionary and a filter condition. How to filter a dictionary by … … key so that only those (key, value) pairs in the dictionary remain where the key satisfies the condition? … value so that only those (key, value) pairs remain where the value satisfies the condition? In this tutorial, you’ll learn … Read more

How to Convert a Float List to a String List in Python

The most Pythonic way to convert a list of floats fs to a list of strings is to use the one-liner fs = [str(x) for x in fs]. It iterates over all elements in the list fs using list comprehension and converts each list element x to a string value using the str(x) constructor. This … Read more

Python Programming Tutorial [+Cheat Sheets]

(Reading time: 19 minutes) The purpose of this article is to help you refresh your knowledge of all the basic Python keywords, data structures, and fundamentals. I wrote it for the intermediate Python programmer who wants to reach the next level of programming expertise. The way of achieving an expert level is through studying the … Read more

How to Install the Solidity Compiler via Source Code Compilation?

In this article, we’ll produce, i.e., compile a Solidity compiler from its source code. Platform compilation is not an operation regular computer users explicitly do very often, if ever. However, in some unusual situations, we need specific software in terms of its (previous) version, or it should run in our exotic environment, etc. Regardless of … Read more