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