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