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