这道题的目的是找出来target在列表中的位置。不知道为啥分类在hard。代码如下:
class Solution(object):
def search(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: int
"""
try:
return nums.index(target)
except:
return -1