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