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