Every Python Method That Returns None (And Why It Breaks Servers)

my_list = my_list.sort() doesn’t sort your list. It sets it to None. data = [3, 1, 2] data = data.sort() print(data) # None ← the list is gone This is deliberate. In Python, a method that modifies an object in place returns None — precisely so you can’t chain it and lose the original by […]
Stani’s Python Editor: How to install and use
Introduction to Stani’s Python Editor Stani’s Python Editor, often referred to simply as SPE, is a versatile-integrated development environment (IDE) specifically designed for Python programming. Created with the aim of making coding in Python more accessible, SPE offers a range of features tailored to both novice and experienced developers. It emphasizes simplicity while providing powerful […]
Python split(): How It Works and the Traps It Hides

split() breaks a string into a list of substrings. It’s one of the most used methods in Python, and one of the most misunderstood — because calling it with no argument and calling it with a space do different things. “a b”.split() # [‘a’, ‘b’] “a b”.split(” “) # [‘a’, ”, ‘b’] ← an empty […]
If, elif and else in Python: Conditionals Explained

A conditional runs one block of code or another, depending on whether something is true. age = 20 if age >= 18: print(“Adult”) else: print(“Minor”) # Adult Python’s version has three things worth knowing early. There are no braces — indentation defines the block. The middle branch is elif, short for else if. And if […]
Trim in Python: It’s Called strip(), and Here’s How It Works

Python has no trim() method. The equivalent is strip(). text = ” Hello, World! ” print(text.strip()) # ‘Hello, World!’ If you’ve come from JavaScript, PHP or Java, trim() is what you’re looking for — and strip() is the name Python gave it. There is no trim built-in, no trim method on strings, and none on […]
Pandas in Python: A Practical Guide with Real Output

Pandas is the library that turns a CSV file into something you can query, filter and summarise in a few lines of Python. If you’ve worked with spreadsheets, the mental model transfers: a DataFrame is a table with named columns, and most of what you do is selecting parts of it, changing them, or summarising […]
init in Python: How Object Initialisation Works

__init__ is the method Python calls automatically when you create an object. It’s where you set the object’s initial attributes. class Car: def __init__(self, make, model): self.make = make self.model = model car = Car(“Toyota”, “Corolla”) print(car.make) # Toyota You never call it directly. Writing Car(“Toyota”, “Corolla”) runs it, and the arguments you pass go […]
Sets in Python: Operations, Operators and When They’re Faster

A set holds unique items with no order. Duplicates are discarded automatically, and you can’t index into one. numbers = {1, 2, 2, 3} print(numbers) # {1, 2, 3} ← the duplicate is gone That’s the obvious part. The reason to care is speed. Checking whether an item is in a set takes the same […]
Python append(): How It Works, and append vs extend

append() adds one item to the end of a list. That’s the whole job. letters = [“a”, “b”] letters.append(“c”) print(letters) # [‘a’, ‘b’, ‘c’] ⚠️ One correction before anything else: append is not a module. There’s no import append, nothing to install, and no documentation page of its own. It’s a method that belongs to […]
Python input(): How to Read and Validate User Input

input() always returns a string. Always — even when the user types a number. That single fact causes most of the bugs people hit with it: comparisons that fail, arithmetic that throws TypeError, and validation that passes when it shouldn’t. This guide covers how input() actually works, how to convert what it returns, and how […]
Null in Python: None Explained, and the Mistakes It Causes

Python has no null. It has None — and the difference is more than naming. None is a singleton object of type NoneType. There is exactly one of it in the entire runtime, and every variable holding “nothing” points to that same object. That single fact explains most of the rules around it. This guide […]
Python Switch Case: match/case and the Alternatives

Python has a switch statement. It arrived in version 3.10, it’s called match/case, and it does considerably more than switch does in other languages. For years the answer to “does Python have switch?” was no, and developers used dictionaries or long if/elif chains instead. That changed with PEP 634, and a lot of material online […]
Lists in Python: Methods, Slicing and the Copy Trap

A list in Python holds an ordered sequence of items, written between square brackets. It can hold anything, and it can be changed after it’s created. fruits = [“apple”, “banana”, “orange”] print(fruits[0]) # ‘apple’ print(len(fruits)) # 3 That mutability is what makes lists useful and what causes their sharpest bugs — two variables can point […]
While Loops in Python: Conditions, break and Infinite Loops

Use a while loop when you don’t know how many repetitions you’ll need. i = 0 while i < 5: print(i) i += 1 # 0 1 2 3 4 That’s the whole distinction from for. A for loop walks through a collection you already have; a while loop repeats until a condition changes — […]
Strings in Python: Creating, Formatting and Manipulating

A string in Python is a sequence of characters, written between quotes, and it cannot be changed after it’s created. name = “Hello” name[0] = “J” # TypeError: ‘str’ object does not support item assignment That immutability is the fact everything else follows from. Every method that appears to modify a string — upper(), replace(), […]
Python range(): The Stop Value Is Excluded, and Other Essentials

range() generates a sequence of integers — and the first thing to know is that the end value is excluded. list(range(1, 10)) # [1, 2, 3, 4, 5, 6, 7, 8, 9] ← nine numbers, not ten That single rule accounts for most off-by-one errors with it, and it’s consistent with the rest of Python […]
For Loops in Python: enumerate, zip and the Mutation Trap

Python’s for loop iterates over the items of a collection, not over a counter. fruits = [“apple”, “banana”, “orange”] for fruit in fruits: print(fruit) # apple # banana # orange That’s the difference from C, Java and JavaScript, where a for manages an index and you fetch items with it. In Python, the loop hands […]
Python len(): How It Works and What It Actually Counts

len() returns how many items an object contains. It takes exactly one argument, always returns an integer, and runs in constant time regardless of size. That last part surprises people: len() on a list of a million items is exactly as fast as on a list of three. It doesn’t count — it reads a […]
What is Python? Understand everything about this language.
Python is a high-level, open-source, interpreted programming language that has become one of the most popular and widely used in software development. Founded in 1989 by Guido van Rossum, Python is known for its ease of learning, clear and concise syntax, and wide range of applications, including web development, data science, machine learning, automation of […]
Python Print Without Newline: end, sep and flush Explained

To print without a line break in Python, pass end=”” to print(). print(“first”, end=””) print(“second”) # firstsecond That’s the whole answer. This guide covers what else end can do, the sep parameter that controls what goes between arguments, and the flush=True that makes progress bars actually work — which is where most people get stuck […]