Python Trim String [Ultimate Guide]

You’ve probably landed on this article because you’re working on a code project with textual data that has some leading or trailing whitespaces. There’s only one question you want to be answered: How to get rid of those whitespaces? So without wasting any more of your time, let’s get to the core! How to Trim … Read more

List Comprehension in Python — A Helpful Illustrated Guide

List Comprehension

List comprehension is a compact way of creating lists. The simple formula is [expression + context]. Expression: What to do with each list element? Context: What elements to select? The context consists of an arbitrary number of for and if statements. The example [x for x in range(3)] creates the list [0, 1, 2]. Being … Read more

Matplotlib Animation – A Helpful Illustrated Guide

Photo by Gensa Hub on Unsplash

Creating animations in matplotlib is reasonably straightforward. However, it can be tricky when starting, and there is no consensus for the best way to create them. In this article, I show you a few methods you can use to make amazing animations in matplotlib. Matplotlib Animation Example The hardest thing about creating animations in matplotlib … Read more

How to Do a Backslash in Python?

The Python backslash (‘\’) is a special character that’s used for two purposes: The Python backslash can be part of a special character sequence such as the tab character ‘\t’, the newline character ‘\n’, or the carriage return ‘\r’. The Python backslash can escape other special characters in a Python string. For example, the first … Read more