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