Level 9 : What is the output?


def add_to(num, target=[]):
    target.append(num)
    return target

print(add_to(1))
print(add_to(2))
print(add_to(3, []))
print(add_to(4))

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