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