For Loop Dilema [python-list]

arya.kumar2494 at gmail.com arya.kumar2494 at gmail.com
Mon Feb 26 13:26:55 EST 2018


On Monday, February 26, 2018 at 8:51:35 PM UTC+5:30, Ian wrote:
> On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki <songofacandy at gmail.com> wrote:
> > https://docs.python.org/3.6/library/itertools.html#itertools.product
> 
> I don't see how you would use itertools.product to do what the OP
> asked for. You could use itertools.chain.from_iterable, though:
> 
> py> names = ['Jack', 'Susan']
> py> list(chain.from_iterable(names))
> ['J', 'a', 'c', 'k', 'S', 'u', 's', 'a', 'n']

if you want to access a dict per say insisde a list or maybe some data i.e deep nested in some mixture of ds wont it be relevant to use a single for statement to query the data out.(Just a thought)
Students = [{"name":John,"age":16},{"name":Maria,"age":18}]

for info in student in Students:
             print(student[info])






More information about the Python-list mailing list