分2步完成:删除所有0,再根据原列表中0的数量添加到末尾
lists = [1,0,0,3,2] j = lists.count(0) while 0 in lists: lists.remove(0) n = 0 while n < j: lists.append(0) n += 1 print(lists)
分2步完成:删除所有0,再根据原列表中0的数量添加到末尾
lists = [1,0,0,3,2] j = lists.count(0) while 0 in lists: lists.remove(0) n = 0 while n < j: lists.append(0) n += 1 print(lists)