On Monday, February 26, 2018 at 6:20:06 AM UTC+5:30, Ian wrote: > On Sun, Feb 25, 2018 at 11:19 AM, <arya.kumar2...@gmail.com> wrote: > > Why we don’t use: > > > > for _ in _ in _ > > > > Instead of > > > > for _ in _: > > for _ in _: > > > > Ex: > > > > Names = ["Arya","Pupun"] > > > > for name in Names: > > for c in name: > > print(c) > > > > instead use: > > > > for c in name in Names: > > print(c) > > It doesn't seem very intuitive (doesn't follow proper English > phrasing, for instance) and I don't think it's a common enough > situation to warrant adding a special syntax for it. But if you really > want it, you could use something like this: > > def double_for(iterable): > for outer in iterable: > yield from outer > > for c in double_for(Names): > print(c) > > But I don't think this is any clearer than making the loops explicit.
Thank you. -- https://mail.python.org/mailman/listinfo/python-list