题目描述请点击查看LeetCode 题目描述
Python3 代码解答如下:
class Solution:
def removeElement(self, nums, val):
"""
:type nums: List[int]
:type val: int
:rtype: int
"""
i = 0
for j in range(0,len(nums)):
if nums[j]!=val:
nums[i] = nums[j]
i += 1
print(nums)
return i