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