write a program to print the index of the last occurence of the given number N in the list
def func(list1):
n = eval(input('Enter no here: '))
list2 = list1[::-1]
n1 = len(list1)-1
if n in list2:
print(n1 - list2.index(n))
func([1,2,3,4,2,6,7])
Enter no here: 2
4
Comments
Leave a comment