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