Bottom Page

Thread Rating:
  • 3 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 help on understanding this output
#1
>>> flist = []
>>> for i in range(3):
...     flist.append(lambda: i)
...
>>> [f() for f in flist]   # what will this print out?
Why is the above output [2,2,2]?

Thanks,

L
Quote

Top Page

Messages In This Thread
help on understanding this output - by landlord1984 - Mar-08-2017, 08:05 PM
RE: help on understanding this output - by zivoni - Mar-08-2017, 08:29 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  understanding output of bytes/raw data rootVIII 3 476 Aug-01-2019, 01:00 PM
Last Post: rootVIII
  Understanding "help()" output? Athenaeum 4 1,331 Sep-29-2017, 09:47 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)