Level 1 : What is the Output?


funcs = []
for i in range(3):
    funcs.append(lambda i=i: i)

print([f() for f in funcs])

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