Using For Loops in Python (with Examples)
The basic In Python, a for loop is a type of loop that is used to iterate over a sequence of items, such as a list, a tuple,…
Python: Return Multiple Results from a Function (3 Ways)
This concise, example-based article will walk you through 3 common approaches for returning multiple results from a function in Python. Without any further ado, let’s get started. Using…
Python: Using async/await with loops (for & while loops)
This concise, practical article will walk you through some examples that showcase different scenarios for using the async and await keywords with for loops and while loops in…
Python asyncio.run() function (with examples)
Overview The asyncio.run() function was introduced in Python 3.7 (which was released in 2018). It is a high-level API that creates an event loop, runs the coroutine in…
List element-wise operations in Python
List element-wise operations refer to performing operations on corresponding elements of multiple lists in a pairwise manner. These operations allow you to apply a function or operator to…
Python: Generate a Dummy List with N Random Elements
To generate a dummy list with n random elements in Python, you can use the random module along with list comprehension. Here’s a step-by-step guide: 1. Import the…
Python: Passing a List to a Function as Multiple Arguments
In Python, passing a list as multiple arguments using the unpacking operator * provides a convenient way to supply a variable number of arguments to a function. It…
Python: Declaring Lists with Type Hints (7 Examples)
In Python 3.5 and above, when working with lists (especially complex lists), you can use type hints to clarify the expected type of list elements, enable static type-checking…
Python: Separate a List into Equally Sized Chunks
This concise, straight-to-the-point article will walk you through a couple of different approaches to splitting a given Python list into equally sized chunks (the last chunk might contain…
Python map() function: Tutorial & examples
The Fundamentals map() is a built-in function in Python that applies a given function to each item in an iterable (e.g., a list, tuple) and returns an iterator…