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