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