programming

Python List extend() Method

Learn Python list extend() method with examples. Add items from another list, tuple, set, string, or dictionary, and understand extend() vs append(), +, and +=.

Deepak Prasad7 min read
programming

Python While Loop Examples

Learn Python while loop with simple examples, including syntax, counter loops, user input, break, continue, while else, nested while loops, and multiple conditions.

Deepak Prasad8 min read
programming

Python len() Function

Learn Python len() function with simple examples. Get the length of strings, lists, tuples, dictionaries, sets, ranges, and custom objects, and fix common TypeError mistakes.

Deepak Prasad7 min read
programming

Python *args and **kwargs

Learn Python *args and **kwargs with simple examples. Understand positional arguments, keyword arguments, how to iterate over kwargs, and how to pass args and kwargs to another function.

Bashir Alam5 min read
programming

Python Join List

Learn how to join a list in Python using str.join(), including lists of strings, numbers, mixed values, separators, newline joins, and common TypeError fixes.

Bashir Alam5 min read
programming

Python One Line If Else

Learn how to write Python if else in one line using the conditional expression syntax. Includes one-line if, if else, if elif else, nested conditions, and common mistakes.

Deepak Prasad8 min read
programming

Python isupper() Method

Learn Python isupper() method with examples. Check if a string is uppercase, understand return values for numbers, symbols, spaces, empty strings, and compare isupper() with upper(), islower(), and isalpha().

Bashir Alam5 min read
programming

Get GPS Coordinates in Python

Learn how to get latitude and longitude in Python from an address using geopy, and how to get approximate current location from an IP address.

Azka Iftikhar6 min read
programming

Python Get Home Directory

Learn how to get the current user's home directory in Python using pathlib Path.home(), os.path.expanduser('~'), and environment variables like HOME and USERPROFILE.

Bashir Alam5 min read
programming

Python Function Examples

Learn Python functions with simple examples, including def syntax, calling a function, parameters, return values, default arguments, keyword arguments, *args, **kwargs, and common mistakes.

Deepak Prasad8 min read
programming

Python filter() Function

Learn Python filter() function with simple examples. Filter lists, strings, dictionaries, and objects using normal functions, lambda functions, filter(None), and list comprehension alternatives.

Bashir Alam7 min read
programming

Python for Loop in One Line

Learn how to write a Python for loop in one line using list comprehension, generator expressions, for with if condition, if else expression, and simple inline loop examples.

Bashir Alam6 min read
programming

Python Flatten List

Learn how to flatten a list of lists in Python using list comprehension, itertools.chain.from_iterable, nested loops, recursion for deep nesting, and NumPy, plus when to avoid sum() on large data.

Bashir Alam5 min read
programming

Python for Loop

Learn Python for loop syntax with simple examples using lists, strings, range(), dictionaries, nested loops, break, continue, pass, and for else.

Deepak Prasad6 min read
programming

Python YAML to Dictionary

Learn how to read a YAML file into a Python dictionary using PyYAML safe_load(), access nested YAML values, load multiple YAML documents, handle errors, and convert dict back to YAML.

Deepak Prasad6 min read
programming

Python Concatenate Lists

Learn how to concatenate, combine, and merge lists in Python using the + operator, extend(), +=, unpacking, itertools.chain(), and list comprehension, with examples and common mistakes.

Deepak Prasad8 min read
programming

Python Copy String

Learn how to copy a string in Python, why assignment is usually enough for immutable strings, and when slicing, str(), copy.copy(), or deepcopy() are unnecessary.

Deepak Prasad7 min read
programming

Python Password Input with Asterisks

Learn how to take password input in Python and show asterisks while typing using getpass echo_char, pwinput, and stdiomask, with examples and common mistakes.

Azka Iftikhar6 min read
programming

Python Concatenate Strings: +, f-strings, join, and +=

Learn how to concatenate strings in Python with +, f-strings, str.join, +=, spaces, mixing variables and numbers, performance in loops, mistakes, and a quick reference table.

Deepak Prasad6 min read
programming

Python Copy List: Assignment, copy.copy(), and deepcopy()

Learn how to copy or clone a Python list using assignment, shallow copy.copy(), list slicing, list.copy(), and copy.deepcopy(), with examples that show when nested objects are shared or independent.

Deepak Prasad8 min read
programming

Python ceil() Function

Learn Python ceil() using math.ceil() with examples for positive and negative numbers, ceiling division, ceil vs floor, integers, floats, and common mistakes.

Bashir Alam6 min read
programming

Python Class Example

Learn Python classes with simple examples to create a class, create objects, use __init__ and self, define attributes and methods, class variables, inheritance, and common mistakes.

Bashir Alam7 min read
programming

Global Variables in Python: global, local, nonlocal, and modules

Learn Python global vs local variables, when to use the global and nonlocal keywords, reading and writing globals from functions, mutables, modules, common mistakes, and a quick reference table.

Deepak Prasad7 min read
programming

Get Size of Priority Queue in Python: qsize, empty, and maxsize

Learn how to get the size of a Python PriorityQueue with qsize(), compare it to empty() and full(), understand approximate counts under threads, and relate current size to maxsize.

Bashir Alam6 min read
programming

Python Delete File

Learn how to delete a file in Python using pathlib Path.unlink(), os.remove(), and os.unlink(), including delete-if-exists examples, error handling, and deleting all files in a folder.

Bashir Alam7 min read
programming

Fix Unknown Time Zone Error in Google Calendar API

Fix Google Calendar API unknown time zone errors by using IANA time zone names, RFC3339 date-time strings with offsets, and Python zoneinfo—avoid ambiguous abbreviations like IST or PST.

Deepak Prasad11 min read
programming

Python property deleter

Learn how Python property deleter works with @property, @name.setter, and @name.deleter, including how del obj.attr calls the deleter method and common mistakes.

Bashir Alam6 min read
programming

Python Exit Program

Learn how to exit a Python program or script using sys.exit(), exit(), quit(), return, and break, including exit codes, messages, functions, loops, and common mistakes.

Bashir Alam7 min read
programming

Python enumerate() Function

Learn Python enumerate() with simple for loop examples. Use enumerate() to get index and value while looping through lists, strings, tuples, dictionaries, and files.

Deepak Prasad7 min read
programming

Python Dictionary Explained

Learn Python dictionary with simple examples, including dictionary syntax, creating dictionaries, accessing values, adding and updating items, looping, checking keys, removing items, and common dictionary methods.

Deepak Prasad8 min read