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