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