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 | 1736+ Python FAQs | Share
input-function | arithmetic-operation | operators | syntax | init | syntax-error | operand | numeric | global-keyword | objects | classes | loops | arithmetic-expression | context-manager | regular-expression | filter-function | counter-function | pseudocode | pandas | dictionary | attribute | input | command-line-parsing | precedence-and-associativity | control-statement | version-check | mysql | floating-point-precision | max-min | staticmethod | bitwise-operator | generator | random | goto-function | class-and-object | built-in-function | destructor | zip | functions | decorator | encoding | numpy | built-in | update | mathematical-function | matplotlib | file_handling | control-flow | oops | identifier | input-function | name-mangling | min-max-function | call | slice | type_conversion | collections | else-statement | python-history | fabs-function | iterator | data-structures | pep | sys | exception-handling | import-method | raise | descriptors | global-variable | while-else-loop | syntax-error | choice | statement | turtle | application | postfix | pickling-&-unpickling | append | generators-in-python | shallow-copy | heap-memory | mutable | conditional-statement | python_version | conditional-statement | zfill-function | string-method | expression | list-mutation | int | sorting | print-statement | sum-function | scientific-notation | multiprocessing | python-module | lists | static-method | indexing | threading | enumerate() | matrix | loop | interpreter | software-design | decimal | control-flow | list-vs-tuple | datetime | inheritance | exception-handling | filter | namedtuple | print | round-function | comprehension | list-indexing | list-comprehension | swapping | nested-loop | yield | type-conversion | string-formatting | overflow | logical-operator | id-function | library | gil | multithreading | class | regex | multiple-inheritance | binary | string-manipulation | slicing | built-in-function | range | access-modifier | iterable | min-function | map-function | file | exponentiation | indentation | parameter | functional-programming | bitwise | set | recursion | __future__ | for | __init_subclass__ | list | operator | data-type | operations | tuple | memory-management | dictionaries | asyncio-module | odd-number | touples | complex-number | identity-operator | boolean-and-non-boolean | constructor | lambda | generators | asyncio | compute | comment | file-handling | list-slicing | encapsulation | global-variable | polymorphism | logical-operation | list-operation | basic | string-slicing | mapping-function | condition | integer | set-operation | python-django | round | default-mutable-argument | operator-overloading | factorial-function | string-formatting | with-statement | design-principle | global | binary-operation | copy | string-iteration | expand-tab | data-structure | mathematics | recurssion | python | list-join | class-and-inheritance | join | debugging | operator-and | immutability | complex | function-and-scope | dicts | python-repl | array | precedence | virtual-environment | data-type | lambdas | operator-or | error | boolean | math-copysign | string | __all__-attribute | syntaxerror | head-and-tail | method | namespace | lambda-function | format | logical-operator | function | async | string-slicing | assignment-operator | deep-copy | package-management | higher-order-function | bitwise-operator | split | immutable-data-type | rollback | feature | keyword | math | datatype | string-method | typeerror | sys-module | match | sum() | list-method | object-attribute | formal-and-actual-parameter | random-function | magic-method | identity-operator | file-handling | benefit | comparison | module | loop-control | list-comprehension | collection | version | sorted | counter | docstring | while-loop | center | inherit | data-structure | installation | oop | zip-function | virtual-environment | frozenset | thread | variable | exception | while-and-for-loop | escape-operator | implementation | matrix-list-comprehension | tuple-unpacking | return-statement | string-concatenation | error-handling | invalid-list | conversion | type-conversion | data_structure | stack | class-and-instance-variable | assert | methods | memory | def | function-argument ...