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

How to Read All Lines of a File in a Python One-Liner?

Say your file is stored in file ‘code.py’. Now, you can open the file, read all lines, get rid of leading and trailing whitespace characters, and store the result in a Python list in a single line of code. Here’s the code: Python is beautiful! ? Try it Yourself: Where to Go From Here? If … Read more

How to Sort a List Alphabetically in Python?

Problem: Given a list of strings. Sort the list of strings in alphabetical order. Example: Solution: Use the list.sort() method without argument to solve the list in lexicographical order which is a generalization of alphabetical order (also applies to the second, third, … characters). Try It Yourself: Related articles: The Ultimate Guide to Python Lists … Read more

Python List sort() – The Ultimate Guide

Every computer scientist loves sorting things. In this article, I’ll show you how Python does it—and how you can tap into the powerful sorting features of Python lists. Definition and Usage: The list.sort() method sorts the list elements in place in an ascending manner. To customize the default sorting behavior, use the optional key argument … Read more

Python: How to Count Elements in a List Matching a Condition?

I stumbled across this question when browsing through StackOverflow and it got me thinking: what’s the best way to count the number of elements in a list that match a certain condition? Can you generalize this way to both general conditions (e.g. x>3) and regular expressions (e.g. ‘a.*’)? Short answer: you can count the number … Read more

Python One-Liners – The Ultimate Collection

This resource is meant to be the ultimate collection of Python One-Liners. If you have an idea for a one-liner to be published here, send me a message to chris (at) finxter.com. Find All Indices of an Element in a List Say, you want to do the same as the list.index(element) method but return all … Read more

Python List index() – A Simple Illustrated Guide

This tutorial shows you everything you need to know to help you master the essential index() method of the most fundamental container data type in the Python programming language. Definition and Usage: The list.index(value) method returns the index of the value argument in the list. You can use optional start and stop arguments to limit … Read more

Python List count()

This tutorial shows you everything you need to know to help you master the essential count() method of the most fundamental container data type in the Python programming language. Definition and Usage: The list.count(x) method counts the number of occurrences of the element x in the list. Here’s a short example: In the first line … Read more

Coding Doctor Against COVID-19

COVID-19 is everywhere. In this article, I want to express my deep gratitude for the doctors, nurses, and medical personnel working 70-hours or more per week to mitigate the adverse effects of the virus. Here’s a pic of Finxter user Albrecht, a “retired” medical doctor supporting a COVID-19 test station in Germany: I asked the … Read more

Python Regex Quantifiers – Question Mark (?) vs Plus (+) vs Asterisk (*)

In this tutorial, I’ll show you the difference of the regular expression quantifiers in Python. What’s the difference between the question mark quantifier (?), the plus quantifier (+), and the asterisk quantifier (*)? Say, you have regular expression pattern A. Regex A? matches zero or one occurrences of A. Regex A* matches zero or more … Read more