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