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