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