How to Convert a Hexadecimal String to Bytes in Python

How to convert hexadecimal string to bytes in Python

Recently, I was working on a project where I had to process some raw data coming from a hardware device in the US supply chain. The device was sending information in hexadecimal string format, and I needed to convert it into bytes so that I could store and analyze it properly. At first, this looked … Read more >>

Remove Empty Strings from a List in Python

Python program to remove empty strings from a list of strings

As a developer, I was cleaning up a dataset in Python where I had a list of customer names collected from an online survey. The issue? Some entries were completely blank. These empty strings were messing up my analysis, and I needed a quick way to remove them. If you’ve ever worked with real-world data … Read more >>

How to Exit an If Statement in Python

How to exit an if statement in Python

I was working on a project where I needed to stop executing code inside an if statement once a certain condition was met. At first, I thought Python might have a direct “exit if” keyword, but it doesn’t. Instead, Python gives us multiple ways to exit an if block depending on whether we’re inside a … Read more >>

Fix the Python 3 Pickle TypeError

a bytes-like object is required not list

When I first started working with the Python pickle module in Python 3, I ran into a frustrating error: This error often happens when we try to use pickle in text mode instead of binary mode. It confused me at first, but after a few trials, I figured out the exact cause and how to … Read more >>

Python Program to Find the Last Day of a Month

Python program to get last day of month

Recently, I was working on a payroll automation project where I needed to calculate the last day of each month. The challenge was that months don’t all have the same number of days, and leap years add another layer of complexity. Since I’ve been coding in Python for more than a decade, I’ve run into … Read more >>

Check N-Digit Armstrong Numbers in Python

armstrong number in python

While I started teaching Python, one of the most common beginner questions I got was about Armstrong numbers. It’s a simple concept, but it’s also a great way to practice loops, conditionals, and functions in Python. In this tutorial, I’ll show you three different methods to check N-digit Armstrong numbers in Python. I’ll also provide … Read more >>

Declare a Variable Without Assigning a Value in Python

How to Declaring a Variable Without Assigning it a Value in Python

As a developer, I was working on a large data processing project for a client in California. I faced a situation where I needed to declare variables first and only assign values later in the program. If you have been coding in Python for a while, you know that, unlike some other programming languages (like … Read more >>

How to Print a New Line After a Variable in Python

python print new line

When I first started coding in Python more than a decade ago, one of the simplest things that tripped me up was printing text exactly the way I wanted. I often needed to display a variable on one line and then move directly to the next line for clarity. At first, I didn’t realize how … Read more >>

How to Get the First Character of a String in Python

Get the first characters of a string in Python

I was working on a project where I needed to quickly check the first letter of customer IDs stored in a database. At first, I thought there might be only one way to do this. But after experimenting, I realized Python offers several simple methods to extract the first character of a string. In this … Read more >>

Remove Brackets from Python Strings

How to remove brackets from Python string

Recently, while working on a data-cleaning project, I ran into a problem where my dataset had unnecessary square brackets around values. For example, instead of “New York”, the data looked like “[New York]”. If you’ve ever imported lists or JSON data into Python, you’ve probably seen this happen too. At first glance, it looks small, … Read more >>

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.