class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums[:] = [nums[x] for x in range(len(nums)) if nums[x] != nums[x1] or x == 0]
return len(nums)
Simple Python solution

Why is it that when I try to shorten the code so it looks like the below, I can't get all the test cases correct?. Also, in OP's solution, how can you return len(nums) and have python know that you're actually referring to the nums[:] that was created?
class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ return len([nums[x] for x in range(len(nums)) if nums[x] != nums[x1] or x == 0])