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