How To Flatten A List Of Lists In Python (Examples & No Imports)
Recently, I had an exercise where I needed to flatten a two-dimensional list down to just one dimension, something where I needed the result to be like this: [[1, 2, 3], [4, 5, 6],...
How To Flatten A List Of Lists In Python (Examples & No Imports)
Recently, I had an exercise where I needed to flatten a two-dimensional list down to just one dimension, something where I needed the result to be like this: [[1, 2, 3], [4, 5, 6],...
In Python there is a handy function to determine the data type of any variable, and it is aptly called type(). This function can help to assess whether a variable is of a certain data type to help...
Python For Loop One Liner With IF Conditions [Code Examples]
There have been times when I wanted to perform a simple for-loop filter operation on a list, and I've often wondered if there's a quick and simple way to do this without having to import any...
Python: Get Average Of Two Dimensional List – No Imports [Code Examples]
In my previous article where I found the average of a list in Python without using imports, in this article I want to expand how you could apply the same concept, but to two-dimensional lists....
Python: Sort 2D Array By Multiple Columns With 1 Line Of Code
How do you sort a two-dimensional array in Python easily without importing libraries? Thankfully, there are some native functions in Python which make sorting arrays a breeze. I recently had a...
Python: Average Of List Of Numbers – Without Imports [One-Liner]
How do you calculate the simple average of a list of numbers in Python, without needing to import any libraries? Unfortunately, there's no native average or avg function in Python to easily...