Level 1 : What will be the output of the Python Program to flatten a nested list without using recursion


a=[[5,[[4]],[[[2]]]],[[3],1]]
flatten=lambda l: sum(map(flatten,l),[]) if isinstance(l,list) else [l]
print(flatten(a))

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