Complete the codeExercise 6/7Elementary20 XP

Where is the value?

Task

The function najdi(zoznam, hodnota) should return the index of the first occurrence of the value, or -1 if it is not in the list. Fill in ___.

Examples

  • Call

    print(najdi([5, 3, 8], 8))

    Expected output

    2
  • Call

    print(najdi([5, 3, 8], 7))

    Expected output

    -1

Rules

  • Replace ___ with the right code.

After you submit, 2 hidden tests will also check your solution: several occurrences, an empty list.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.