Level 10 : What will the following code snippet produce?


def func(a, b=[]):
    b.append(a)
    return b

list1 = func(10)
list2 = func(20, [])
list3 = func(30)
print(list1, list2, list3)

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