How to Check if an Object is Iterable in Python

How to check if an object is iterable in Python

While working on a data processing script, I needed to loop through a list of customer records. The issue was, I wasn’t sure if the object I received from an API was even iterable. If you’ve been coding in Python for a while, you’ve probably run into the same problem. Sometimes, you expect a list … 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 >>

How to Capitalize Alternate Letters in a String in Python

Alternate the case of each letter in a given string in Python

When I was working on a text formatting project, I needed to make strings look “stylized” by capitalizing every alternate letter. At first, I thought Python might have a built-in function for this. But soon, I realized I needed to use a combination of string methods, slicing, and loops to achieve it. In this tutorial, … Read more >>

Get the First and Last Digit of a Number in Python

Get first and last digits of a number in Python

Recently, I was working on a project where I needed to extract the first and last digit of a number in Python. At first, I thought Python might have a built-in function for this. But just like in Excel, where some features require workarounds, in Python, we need to use a few tricks. In this … Read more >>

Get the First Digit of a Number in Python

how to get first digit of a number in python

I was working on a project where I needed to extract the first digit of a number in Python. At first, it sounds simple, but depending on the approach you use, there are multiple ways to solve this. As someone who has been writing Python code for more than 10 years, I’ve faced this requirement … Read more >>

How to Remove NaN Values from a List in Python

How to remove nan from a list in python

While cleaning a dataset for a project, I ran into an issue where my Python list had a mix of numbers and NaN values. If you’ve worked with real-world data in the US, say, sales reports, healthcare data, or survey results, you know how common missing values can be. The problem is simple: NaN (Not … Read more >>

Traffic Signal Program in Python

write python program for traffic signals

When I first started learning Python more than a decade ago, I loved building small projects that looked like real-world systems. One of my favorites was a traffic signal program. It’s simple, fun, and surprisingly practical. If you live in the USA, you see traffic lights every day, green for go, yellow for slow down, … Read more >>

Find Armstrong Numbers in an Interval in Python

armstrong number in python

I was working on a Python project where I needed to filter out all Armstrong numbers within a given range. Python doesn’t have a direct function for Armstrong numbers either. So, I had to come up with a simple program to check each number in the interval and return only those that qualify as Armstrong … 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.