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

Veröffentlicht am: 16 Dezember 2023
auf dem Kanal: 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


Auf dieser Seite können Sie das Online-Video Python : Flatten a Nested List Using Recursive Function & While Loop mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Grow with Data 16 Dezember 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 159 Mal angesehen und es wurde von 10 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!