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

Опубликовано: 16 Декабрь 2023
на канале: 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


На этой странице сайта вы можете посмотреть видео онлайн Python : Flatten a Nested List Using Recursive Function & While Loop длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Grow with Data 16 Декабрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 159 раз и оно понравилось 10 зрителям. Приятного просмотра!