Level 6 : What will be the output of the following Python code?


list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)

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