Find a Key by Value in a Python Dictionary

get key from value python

Recently, I was working on a Python project where I needed to search for a key based on its value in a dictionary. Since dictionaries are one of the most powerful and frequently used data structures in Python, I decided to explore different ways to solve this problem. In this tutorial, I’ll share five simple … Read more >>

How to Convert Dict_Values to List in Python

How to Convert Dict_Values to List in Python using dict.values() method

When I first started working with Python dictionaries more than a decade ago, I often ran into a common situation. I would use the values() method to access dictionary values and get something called dict_values. At first glance, this dict_values object looks like a list. But when I tried to perform list operations such as … Read more >>

How to Get Filename From Path in Python

Python File Name Using Os Module

The challenge I faced while working on a project was: I needed only the filename, not the full directory path. If you’ve ever worked with file systems in Python, you know how often this comes up. For example, when processing reports from multiple states in the USA, you may have file paths like: But in … Read more >>

Switch Case in Python with User Input 

python switch case

One of the things I missed when I first started working with Python was the traditional switch case statement that I had used in other programming languages like C and Java. In Python, there is no built-in switch case, but over the years, I’ve discovered multiple ways to achieve the same functionality. These methods are … Read more >>

Python If Not Statement – How to Use

python if not

I still remember the first time I came across the if not statement in Python. At that time, I was working on a project analyzing sales data for a retail company in the USA. I had to check if certain values were missing or empty before running calculations. Instead of writing long conditions, I discovered … Read more >>

Fix SyntaxError: invalid syntax in Python

invalid syntax

When I started working with Python, I often ran into the dreaded SyntaxError: invalid syntax message. It was frustrating because sometimes the error didn’t make sense at first glance. I felt like my code looked perfectly fine, but Python kept complaining. Over the years, I’ve learned that syntax errors are usually caused by small mistakes, … Read more >>

How to Perform String Slicing in Python

string slicing in python

While working on a project that involved analyzing customer feedback, I had to extract specific parts of text strings. The challenge was simple: I needed only the first few characters from each customer’s comment. But as I explored further, I realized Python string slicing could do so much more. If you are new to Python, … Read more >>

How to Split a List in Python by Comma

python split string by comma

Recently, while working on a data-cleaning project, I needed to split a long list of values separated by commas into individual items. At first, I thought this would be tricky, but Python makes it surprisingly simple. With over 10 years of experience writing Python code, I’ve used this technique countless times for real-world projects. In … Read more >>

Python File Methods with Examples

python file methods

When I first started working with Python more than a decade ago, one of the most useful skills I learned was how to work with files. In this tutorial, I’ll walk you through the most commonly used Python file methods. I’ll share my firsthand experience, along with practical examples that you can try on your … Read more >>

Create a Dictionary of Lists in Python

python dictionary of lists

I started working with Python more than a decade ago, and one of the most useful data structures I discovered was the dictionary of lists. At first, I used Python dictionaries only for simple key-value pairs. But as my projects grew, I needed a way to store multiple values under a single key. That’s when … 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.