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