Answer to Question #224544 in Python for balaji

Question #224544

write a program to print the index of the last occurence of the given number N in the list



1
Expert's answer
2021-08-09T02:34:47-0400
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS