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