Level 1 : what is the output for the below code


def f(x=[]):
    x.append(1)
    return x

print(f(), f())

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