Level 9 : What happens in Python when you use the += operator on a list?


list1 = [1, 2, 3]
list2 = list1
list1 += [4]

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