Questions
Python questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Check if a String Is Empty in Python
Learn the cleanest ways to check if a string is empty in Python, including truthy checks, exact comparisons, and common mistakes to avoid.
How to Check if a String Is a Number in Python
Learn how to check whether a string represents an int or float in Python using float(), validation patterns, and common pitfalls.
How to Check if an Object Has an Attribute in Python
Learn how to check whether an object has an attribute in Python using hasattr, getattr, and safer real-world patterns.
How to Concatenate Two Lists in Python
Learn how to concatenate two lists in Python using +, extend(), unpacking, and more with examples, mistakes, and practice.
How to Copy a File in Python
Learn how to copy a file in Python using shutil, file objects, and common patterns with simple examples and beginner-friendly explanations.
How to Copy a List in Python Without Changing the Original
Learn why assigning one Python list to another shares the same object, and how to copy lists safely using slice, list(), and copy().
How to Count Item Occurrences in a Python List
Learn how to count how many times a value appears in a Python list using list.count(), loops, and related counting techniques.
How to Create a Directory and Missing Parent Directories in Python
Learn how to create nested directories in Python, including missing parent folders, similar to Bash mkdir -p.
How to Create a Time Delay in Python
Learn how to add a time delay in Python using time.sleep(), with examples, common mistakes, and practical use cases.
How to Create a virtualenv with a Specific Python Version
Learn how to create a virtualenv using a specific Python version, with clear commands, examples, common mistakes, and practical usage.
How to Declare Custom Exceptions in Modern Python
Learn how to create custom exceptions in modern Python, including proper inheritance, args handling, extra data, and string output behavior.
How to Delete a File or Folder in Python
Learn how to delete files and folders in Python using os and shutil, with examples, safety tips, and common mistakes beginners make.
How to Determine a Variable’s Type in Python
Learn how to check a variable’s type in Python using type() and isinstance(), with examples, mistakes, and practical use cases.
How to Determine an Object’s Type in Python
Learn how to check an object's type in Python using type() and isinstance(), with examples, mistakes, and practical use cases.
How to Escape Curly Braces in Python .format Strings
Learn how to escape curly braces in Python .format strings, why double braces work, and how to print literal { and } safely.
How to Execute System Commands in Python
Learn how to run external programs and system commands in Python using subprocess, with examples, safety tips, and common mistakes.
How to Exit a Python Virtual Environment and Return to the System Python
Learn how to leave a Python virtualenv or virtualenvwrapper environment and switch back to your system Python safely.
How to Extract a File Extension from a Filename in JavaScript
Learn how to extract a file extension from a filename in JavaScript, including edge cases like hidden files and names with many dots.
How to Find the Index of an Item in a Python List
Learn how to find the index of an item in a Python list using list.index(), with examples, pitfalls, and real-world usage.
How to Fix "Python.h: No such file or directory" in C Extensions
Learn why "Python.h: No such file or directory" happens when compiling C extensions and how to fix include paths and Python dev headers.