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