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