各位大牛帮我看看这段Python的代码,怎么都运行不对
defremoveDuplicates(nums):defremove_num(nums):a=len(nums)-1print("nums的长度-1为:",a)fori...
def removeDuplicates(nums):
def remove_num(nums):
a=len(nums)-1
print("nums的长度-1为:",a)
for i in range(a):
print('i等于',i)
new_nums = nums[i+1:]
print('nums is ',nums)
print('num[i] is ',nums[i])
print('new_nums is ',new_nums)
if nums[i] in new_nums:
nums.remove(nums[i])
remove_num(nums)
return remove_num(nums)
nums=[0,0,1,1,1,2,2,3,3,4]
removeDuplicates(nums) 展开
def remove_num(nums):
a=len(nums)-1
print("nums的长度-1为:",a)
for i in range(a):
print('i等于',i)
new_nums = nums[i+1:]
print('nums is ',nums)
print('num[i] is ',nums[i])
print('new_nums is ',new_nums)
if nums[i] in new_nums:
nums.remove(nums[i])
remove_num(nums)
return remove_num(nums)
nums=[0,0,1,1,1,2,2,3,3,4]
removeDuplicates(nums) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询