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