My accepted python code


  • 0
    S

    class Solution(object):
    def removeElement(self, nums, val):

        for item in nums[ : ]:
            if item == val:
                nums.remove(item)
                
        return len(nums)

  • 0
    B

    if I change "for item in nums[ : ]:" to "for item in nums:",it's wrong.why ? thanks


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.