改进排序数组的索引:
def deduplication(self, nums):
ifselfin nums: #加入数字是否在数组的判断,不在则打印none
for i in range(len(nums)): #一个for循环加上if else即可找出数组索引
if nums[i]==self:
return i
else:
i +=1
return i
print(deduplication(5,[1,3,5,6])
改进排序数组的索引:
def deduplication(self, nums):
ifselfin nums: #加入数字是否在数组的判断,不在则打印none
for i in range(len(nums)): #一个for循环加上if else即可找出数组索引
if nums[i]==self:
return i
else:
i +=1
return i
print(deduplication(5,[1,3,5,6])