Peter Otten 在 2021年6月15日 星期二下午2:48:07 [UTC+8] 的信中寫道: > On 12/06/2021 04:02, Jach Feng wrote: > > >>>> def foo(): > > ... # do something > > ... > >>>> a = [] > >>>> for i in range(3): > > ... a.append(foo()) > > ... > >>>> a > > [] > The most natural way to achieve something similar is to replace append() > with extend(): > > >>> def foo(): return () > >>> a = [] > >>> for i in range(3): > a.extend(foo()) > > > >>> a > [] Yes, return a list and using extend() to collect value is exactly what I need! Thank you, Christian and Peter.
--Jach -- https://mail.python.org/mailman/listinfo/python-list