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