Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python how to unnest a nested list

# Basic syntax:
unnested_list = list(chain(*nested_list))
# Where chain comes from the itertools package and is useful for 
#	unnesting any iterables

# Example usage:
from itertools import chain
nested_list = [[1,2], [3,4]]
my_unnested_list = list(chain(*nested_list))
print(my_unnested_list)
--> [1, 2, 3, 4]
Comment

PREVIOUS NEXT
Code Example
Python :: ionic python2 Error: not found: python2 
Python :: insta profile downloader in python 
Python :: numpy normal distribution 
Python :: python repeating scheduler 
Python :: cv2 load image 
Python :: add self role with discord bot python 
Python :: how to unzip files using zipfile module python 
Python :: python map input 
Python :: how to trim mp4 with moviepy 
Python :: python requests.get pdf An appropriate representation of the requested resource could not be found 
Python :: zeller year 
Python :: pandas df remove index 
Python :: how to count down in python using turtle graphics 
Python :: string pick the first 2 characters python 
Python :: clear console in python 
Python :: convert int to byte python 
Python :: how to add numbers in python using for loop 
Python :: change py version in colab 
Python :: python divide every element in a list by a number 
Python :: python sorted descending 
Python :: python tkinter fullscreen 
Python :: pandas sort columns by name 
Python :: background image in python 
Python :: python blackjack 
Python :: numpy style docstrings 
Python :: asyncio wirte to text python 
Python :: pythoni me numra 
Python :: python tkinter lable on bottom of screen 
Python :: how to convert async function to sync function in python 
Python :: python blueprint 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =