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