Level 10 : What will be the output?


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

print(func())
print(func())

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