Loading...
Loading...
Loading...
Given a list and a value x, print the position (counting from 0) of the last place where x appears. Print -1 if x is not in the list. The starter holds a program with a bug. Find it and fix it.
Example
Input
5 4 7 4 9 4 4
Output
4
The value 4 is at positions 0, 2 and 4. The last is 4.
Try the problem first. Open one hint at a time.
Loop over every position and remember the latest one that matches.
Do not stop at the first match.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor