Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flatten a list of list itertools

import itertools

regular_list = [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
flat_list = list(itertools.chain(*regular_list))

print('Original list', regular_list)
print('Transformed list', flat_list)
Comment

Flatten List in Python With Itertools

import itertools
List = [[1,2],[5,6],[7,9]]
list_using_itertools = list(itertools.chain(*List))
print(list_using_itertools)
Comment

PREVIOUS NEXT
Code Example
Python :: call class function by string python 
Python :: find email address pytho 
Python :: how to connect ip camera to opencv python 
Python :: find the median of input number in a list and print 
Python :: Binary search tree deleting in python 
Python :: how to use histogram in python 
Python :: streamlit format_func example 
Python :: input and print 
Python :: structural pattern matching python 
Python :: count unique values in python 
Python :: inline if statement python return 
Python :: remove items from list while iterating python 
Python :: python datetime make timezone aware 
Python :: how to get left click input in pygame 
Python :: array slicing python 
Python :: django-storages delete folder 
Python :: Power Crisis 
Python :: create instances of a class in a for loop 
Python :: executing a python script interactively 
Python :: @methodclass in python 
Python :: get first not null value from column dataframe 
Python :: 2d array python 
Python :: python C-like structs 
Python :: plotting mean in density plot ggplot2 
Python :: how to install python packages in local directory 
Python :: how to calculate the google map distance in python 
Python :: python - extract min and max values per each column name 
Python :: Query a PSQL Database From Python 
Python :: fill_between matplotlib 
Python :: Finding if 2 consecutive numbers in a list have a sum equal to a given number 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =