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