Higher Order Functions in Python (With Examples)

Higher order functions in Python: Command Prompt output of sorted, map and filter with key functions

Higher order functions in Python are functions that take another function as an argument, return a function, or both. You already use them: sorted(items, key=…), map() and filter() all accept a function: The output below is from Python 3.12.5, using small order and pricing data. We’ll treat functions as values, pass them to built-ins, return … Read more >>

Fuzzy String Matching in Python (difflib and RapidFuzz)

Fuzzy string matching in Python: RapidFuzz ratio, partial_ratio, token_sort_ratio and WRatio scores

Fuzzy string matching in Python scores how similar two strings are, so “Philadelpia” can still match “Philadelphia”. The standard library’s difflib does it with no installs, and the RapidFuzz package does it much faster with smarter scorers: All scores below come from real runs of Python 3.12.5 with RapidFuzz 3.14.6; install RapidFuzz with pip install … Read more >>

How to Update Python in the Terminal (Windows, Mac, Linux)

How to update Python in terminal: Command Prompt checking the Python version and listing installed versions

Here’s how to update Python in the terminal: on Windows, run py install –update with the Python install manager (or winget upgrade Python.Python.3.14); on a Mac, run brew upgrade python@3.14; on Linux, install the newer version alongside the system one. Then check it: The newest release on python.org in October 2026 is Python 3.14.8. The … Read more >>

Python Quadratic Equation Solver (With Examples)

Python quadratic equation: Command Prompt output of the quadratic formula with two, one and no real roots

For a Python quadratic equation ax² + bx + c = 0, compute the discriminant b² – 4ac and plug it into the quadratic formula. Use cmath.sqrt so negative discriminants give complex roots instead of an error: All roots below were computed on Python 3.12.5 with NumPy 2.5.3, including a program I ran by typing … Read more >>

Web Scraping with Selenium in Python (Step by Step)

Web scraping with Selenium Python: requests finds 0 quotes on a JavaScript page while Selenium finds 10

Web scraping with Selenium in Python means driving a real browser from code, so you can read pages that build their content with JavaScript. Install it with pip install selenium, start a browser, load the page, and find elements: Every example ran headless Microsoft Edge from Python 3.12.5 with Selenium 4.50.0 against quotes.toscrape.com, a practice … Read more >>

Fix: Import “numpy” Could Not Be Resolved (Pylance, VS Code)

Import numpy could not be resolved: the Pylance/Pyright reportMissingImports error in Command Prompt

Import “numpy” could not be resolved is a Pylance warning in VS Code. It means the Python interpreter VS Code is using doesn’t have NumPy installed. Select the right interpreter, or install NumPy into the one that’s selected: Pylance is built on Pyright, so I reproduced the exact message with the Pyright command-line tool and … Read more >>

Python Read File into List (5 Easy Ways)

Python read file into list: Command Prompt output of readlines with newlines and splitlines without them

For a Python read file into list, open the file and call f.read().splitlines(). You get one list item per line, without the newline characters that readlines() leaves behind: The sample files are tiny text and CSV files I created for this, and every example ran on Python 3.12.5. You’ll see readlines() versus splitlines(), cleaning and … Read more >>

Fix: TypeError ‘list’ object is not callable in Python

Python list object is not callable: Command Prompt traceback after shadowing the built-in list

TypeError: ‘list’ object is not callable in Python means you put parentheses after something that’s a list, so Python tried to call it like a function. Usually you named a variable list, or used () where indexing needs []: Every traceback below is real output from Python 3.12.5, with the fix right after it. We’ll … Read more >>

What Does isalpha() Do in Python? (With Examples)

What does isalpha do in Python: Command Prompt output of isalpha on words, spaces, digits and accented letters

What does isalpha do in Python? str.isalpha() returns True when every character in a string is a letter and the string isn’t empty. A single space, digit or punctuation mark makes it False: I tested each example on Python 3.12.5, including accented and non-English letters. You’ll see the basic rules, how to validate names that … Read more >>