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