Python : Flatten a Nested List Using Recursive Function & While Loop

Published: 16 December 2023
on channel: Grow with Data
159
10

Video 27: This video shows how to convert a nested list into a simple flatten list using recursive function and also in simple WHILE loop

Few terminologies here:
1. Nested List: A nested list is a list that contains other lists as its element. Basically its a list within a list, allowing for a hierarchical or multi-dimensional structure to store data
2. Recursive Function: A recursive function calls itself during its execution. The well known example of recursive function is to calculate the factorial of a number, which we can discuss in the future videos

In this example of flatten a nested list, we discussed two options
1. While Loop: This is a simple WHILE loop, where we pop() each element in the list, check if the data type of that element is a list. If its a list, append that list to the current variable and go for the next loop till you clear the variable without any value in it.

2. Recursive Function: we loop in thru the list and check the data type of the element. If its a integer, store it in the output variable. if not, call the same function again and loop through it. Its called the recursive function.

code: https://github.com/jeganpillai/python...

Follow me on,
Website : https://growwithdata.co/
YouTube :    / @growwithdata  
TikTok :   / growwithdata  
LinkedIn :   / growwithdata  
Facebook :   / growwithdata.co  
twitter :   / growwithdata_co  
WhatsApp : https://whatsapp.com/channel/0029VaF8...
Instagram :   / growwithdata.co  


#recursive #countingalgorithm #list #looping #listmanipulation #uniquesubstring #longestsubstring #slicing #lineartimecomplexity #python #pythonquestions #pythontest #pythonprogramming #pythontutorial #python3 #pythonforbeginners #interviewquestions #interview #dataengineers #deinterview #pythoninterview #interviewquestions #leetcode #placementpreparation #meta #google #facebook #apple #netflix #amazon #google #faang #maanga #dataengineers #alphanumeric #nonalphanumeric #growwithdata


On this page of the site you can watch the video online Python : Flatten a Nested List Using Recursive Function & While Loop with a duration of hours minute second in good quality, which was uploaded by the user Grow with Data 16 December 2023, share the link with friends and acquaintances, this video has already been watched 159 times on youtube and it was liked by 10 viewers. Enjoy your viewing!