Level 9 : What is the output for the below code?


funcs = [lambda: i for i in range(3)]
print([f() for f in funcs])

Author: VenuEmmela | Tags: lambdas | 1859+ Python FAQs | Share
generators-in-python | swapping | operations | managing-directories-with-os-and-shutil | loop-control-statements | multithreading | mathematics | literal-characters-and-special-characters | memory | list-method | list,-set,-and-dictionary-comprehensions | int | reading:-read(),-readline(),-readlines() | magic-method | mysql | min-max-function | generator | conversion | mapping-function | logical-operator | static-method | tuple | sys | assignment-operators | collections | __init_subclass__ | identity-operators-(is,-is-not) | threading | map-function | virtual-environment | thread-safe-data-structures-(queue.queue) | class-and-instance-variable | operator-overloading | class | type-conversion-and-casting | list-comprehension | set-operation | anchors-(^,-$) | boolean-masking | assert | syntax | typeerror | global-keyword | head-and-tail | asyncio-module | zip | python | list-slicing | join | method-overloading | center | call | tuples | comment | built-in | indentation | async | numeric | stack | __future__ | object-attribute | list-indexing | classes | return-statement | exponentiation | for | filter | slicing | type-conversion | choice | raise-statement | heap-memory | arithmetic-operation | append | sorted | command-line-parsing | bitwise-operator | bitwise-operator | bitwise | python-module | round-function | random-function | asyncio | docstring | while-else-loop | loops | feature | application | overflow | array | floating-point-precision | binary-operation | matplotlib | logical-operation | nested-loop | polymorphism | zip-function | time-series-with-pandas | logical-operator | multiprocessing | __all__-attribute | basic | attribute | numpy | matrix | namespace | booleans | error | using-map()-for-transformations | gil | access-modifier | while-loop | invalid-list | method | update | parsing-with-strptime | error-handling | thread-synchronization | yield | aggregating-data-with-functools.reduce() | built-in-modules | else-statement | built-in-function | opening-files-(open()) | while-and-for-loop | random | lists | while-loops | built-in-function | python-repl | thread | boolean-and-non-boolean | logical-operators | introduction-to-multiprocessing | why-use-multiprocessing-over-threading?-(gil) | iterator | package-management | iterable | binary | list-join | print-statement | class-and-object | advanced-file-operations | functions | using-the-threading-module | using-else-and-finally | module | zfill-function | variable | postfix | arithmetic-expression | import-method | boolean | list-vs-tuple | parameter | pandas | dataframe-and-series-objects | comparison | working-with-binary-files-(rb,-wb) | lambdas | walking-through-directories-using-os.walk() | compute | integers | descriptors | list-comprehensions | datetime.date,-datetime.time,-datetime.datetime | match | goto-function | with-statement | virtual-environment | tuple-methods | def | loop-control | factorial-function | using-os-and-pathlib-modules | using-yield-in-functions | indexing:-loc-vs-iloc | using-join()-and-is_alive()-methods | version-check | list-comprehension | fabs-function | list-methods-and-slicing | lambda-functions | generators | odd-number | expression | working-with-file-paths | control-flow | enumerate() | file | datetime | datatype | multiple-except-blocks | conditional-statements | pep | oops | error-handling | data_structure | oop | indexing | keyword | touples | using-assertions-(assertequal,-assertraises) | string-methods | recursion | multiple-inheritance | function-and-scope | string | complex-number | creating-custom-modules | decimal | floats | introduction-to-python | function-argument | file-handling | directory-operations | counter-function | identity-operator | single-inheritance | conditional-statement | name-mangling | data-type | immutability | frozenset | dictionary-methods | math | encoding | condition | filter-function | type-conversion | default-arguments | max-min | sorting-and-ranking | lambda-function | tuple-unpacking | escape-operator | formal-and-actual-parameter | membership-operators-(in,-not-in) | working-with-dates-and-times | file_handling | joining-and-merging-dataframes | writing:-write(),-writelines() | math-copysign | print | exception | python-django | encapsulation | data-structure | matrix-list-comprehension | unit-testing | defining-functions | counter | formatting-with-strftime | exception-handling | sum-function | operators | version | using-lists-as-stacks | data-structures-in-python | string-method | installation | namedtuple | data-structure | higher-order-function | id-function | copy | data-type-conversions | working-with-temporary-files-using-tempfile | round | identity-operator | staticmethod | turtle | recurssion | complex | dictionaries | dictionary-comprehensions | destructor | operand | control-statement | global-variable | slice | string-slicing | global | input-function | data-structures | conditional-statement | pseudocode | regular-expression | mutable | reading-and-writing-files | shallow-copy | creating-and-starting-threads | sum() | rollback | string-formatting | syntaxerror | min-function | design-principle | library | else | dictionary | scientific-notation | global-variable | python_version | pass | pickling--unpickling | default-mutable-argument | multiple-inheritance | function | interpreter | operator | list-operation | methods | python-operators | strings | operator-and | overriding-methods | regular-expressions | regex | list-mutation | implementation | functional-programming | init | file-handling | intering | syntax-error | string-iteration | introduction-to-threads | inherit | python-history | input | operator-or | loop | memory-management | split | control-flow | data-types | python-syntax-and-structure | constructor | deep-copy | dicts | difference-between-threads-and-processes | debugging | set | immutable-data-type | comprehension | filtering-and-indexing | collection | objects | string-method | string-slicing | exception-handling | software-design | string-concatenation | functional-programming | decorator | benefit | iterators | range | context-manager | inheritance | precedence-and-associativity | format | precedence | lambda | sys-module | raise | handling-missing-values-(fillna,-dropna) | quantifiers-(*,-+,-?,-{}) | assignment-operator | string-formatting | statement | class-and-inheritance | sorting | integer | key-value-pairs | mathematical-function | string-manipulation | sets | reading-and-writing-large-files-efficiently | arbitrary-arguments-(*args,-**kwargs) | syntax-error | class-decorators | identifier | data-type | input-function | test-discovery | type_conversion | list | expand-tab ...