偷懒写法,emmm看了看题名,想了一下,这应该是让我实现Python的index()吧
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
try:
haystack.index(needle)
return haystack.index(needle)
except:
return -1