How to Use Generator Expressions in Python Dictionaries

Imagine the following scenario: You work in law enforcement for the US Department of Labor, finding companies that pay below minimum wage so you can initiate further investigations. Like hungry dogs on the back of a meat truck, your Fair Labor Standards Act (FLSA) officers are already waiting for the list of companies that violated … Read more

Python List Average

Don’t Be Mean, Be Median. This article shows you how to calculate the average of a given list of numerical inputs in Python. In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of the average: sum over all values and divide them by the number of values. … Read more

100 Code Puzzles to Train Your Rapid Python Understanding

Some coders possess laser-like code understanding skills. They look at a piece of source code, and the meaning pops immediately into their great minds. If you present them with a new code snippet, they’ll tell you in a few seconds what it does. Since I’ve started to train this skill of rapid code understanding in … Read more

Python One-Liners: Sampling A 2D Python List (to Speed Up Machine Learning)

This is a tutorial video from my new book “Python One-Liners” with NoStarch press (San Francisco 2020). Grab your Python One-Liner Superpower now! (Amazon Link) Here’s the code that shows you how to sample a two-dimensional Python list—including only every other list element in the resulting two-dimensional Python list. All of this happens in a … Read more

The Ultimate Guide to Python Lists

The most important collection data type in Python is the list data type. You’ll use lists basically in all your future projects. So take your time and invest a good hour or so to study this guide carefully. Overview — Creating a List in Python There are many ways of creating a list in Python. … Read more

Your Thriving Coding Business — A Shocking Truth (Spoiler Alert: It’s About Value)

Why should you create your own coding business?  Creating a coding business is not for everyone. If you go into this with the mindset of “trying this online business thing”, you won’t be successful. Beginning your coding business is hard work. Your initial work will be unpaid. And you must do it while you’re also forced … Read more

Python List Sort Key

Every computer scientist loves sorting things. In this article, I’ll show you how you can modify the default Python sorting behavior with the key argument. Definition and Usage: To customize the default sorting behavior of the list.sort() and sorted() method, use the optional key argument by passing a function that returns a comparable value for … Read more

Python – How to Sort a List of Dictionaries?

In this article, you’ll learn the ins and outs of the sorting function in Python. In particular, you’re going to learn how to sort a list of dictionaries in all possible variations. [1] So let’s get started! How to Sort a List of Dictionaries … … By Value? Problem: Given a list of dictionaries. Each … Read more