Level 1 : Output of this snippet?


lst = [1, 2, 3, 4]
print(lst.index(5) if 5 in lst else -1)

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