Number 2 present at index locatios 0,6,9, as the last occurrence, is at index 9. So the output should be 9.
Input: 2 4 5 6 7 8 2 4 5 2 3 8
9
nums = [int(n) for n in input().split()]
for i in range(len(nums), 0, -1):
if nums[i-1] == 2:
print(i-1)
break
Comments
Leave a comment