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 >>

Remove Quotes from a String in Python

How to remove quotes from a string in Python

As a Python developer, I was working on a data-cleaning project where I had to process large CSV files exported from a U.S. retail system. The issue was that many of the text fields came wrapped in single or double quotes. At first, I thought Python would have a built-in way to strip quotes from … Read more >>

How to Remove Unicode Characters in Python

python remove unicode characters from string

Recently, I was working on a data-cleaning project where I had to process customer feedback collected from different regions of the USA. The challenge? Many of the text files contained special Unicode characters like emojis, accented letters, and symbols that I didn’t need in my analysis. I quickly realized that removing Unicode characters in Python … Read more >>

Python Stdin, Stdout, and Stderr

python print to stderr

When I was working on a Python script that needed to take input from the command line, display results to the user, and log errors separately. The issue was… I realized many beginners (and even some experienced developers) are not fully aware of how stdin, stdout, and stderr work in Python. So, in this tutorial, … Read more >>

Compare Two Strings Character by Character in Python

How to Compare Two Strings Character by Character in Python

As a developer, I was working on a project where I had to validate text input from users against a stored reference string. The tricky part? I needed to check the strings character by character, not just whether they were equal overall. Over the years, I’ve used multiple approaches to solve this kind of problem … Read more >>

Remove Decimals from a String in Python

How to remove decimals from a string in Python

Recently, I was working on a project where I had to clean up some messy financial data. The data came from different U.S. retail systems, and many of the values had decimals attached to them inside strings. For example, I had strings like “Product123.45” or “Invoice-567.89”. What I really needed was just the integer part … Read more >>

Remove Trailing Zeros from Decimal in Python

How to remove all the trailing zeros from a decimal using a for loop in Python

I was working on a financial reporting project for a client in the USA, and I ran into a common formatting issue. The numbers in my report appeared to be 45.6000 or 120.000. At first glance, this might not seem like a big deal. But when you’re preparing reports for stakeholders, clean and precise formatting … Read more >>

Remove Decimal Numbers in Python

Remove decimal numbers using int() function in Python

When I started working with financial data in Python, I often needed to remove decimal numbers from values. For example, when processing sales reports from different states in the USA, I had to clean up amounts like 1234.56 into 1234. At first, I thought there was just one way to do it. But with more … Read more >>

SyntaxError: Invalid Character in Identifier in Python

invalid character in identifier

While reviewing a client’s automation script, I ran into an error that read: At first glance, it looked confusing because the code seemed fine. However, after digging deeper, I realized the issue was caused by hidden or invalid characters in the script. If you’ve been coding in Python long enough, you’ll likely face this error … Read more >>

Sort a List of Lists in Python

How to sort a list of lists in Python

Recently, I was working on a project where I had to organize student test scores stored in a list of lists. Each sublist contained the student’s name and score. At first, I thought sorting this kind of nested list would be tricky. But after experimenting with Python’s built-in functions, I realized there are several simple … Read more >>