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