iterate through an irregular nested list in Python

2020-03-07 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello -- https:

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jk

Re: iterate through an irregular nested list in Python

2020-03-07 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello -- https:

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jk

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jk

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello -- https:

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Dan Stromberg
On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinnd...@gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jkj

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Souvik Dutta
A better way would be to just do nestedl = [[2], [], [], [l, b, n]]#nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we

Re: iterate through an irregular nested list in Python

2020-03-06 Thread Pieter van Oostrum
sinnd...@gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: >

iterate through an irregular nested list in Python

2020-03-06 Thread sinndhhu
Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello -- https