Level 9 : What is the output?


def test(val, lst=[]):
    lst.append(val)
    return lst

print(test(1))
print(test(2))

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