Level 1 : What is the output of the following code?


names = ["srinu", "krishna", "Mani", "sagar", "chandra"]
newlist = [x for x in names if "a" in x]
print(newlist)

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