Level 3 : What will be the value of ‘result’ in following Python program?


list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

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