第17215题 程序题
补全Python代码实现将列表中的所有零移动到列表尾部

有一组数据[0,20,0,4,31]存放在nums中,请将列表中的所有零移动到列表尾。补全以下Python代码实现该功能:

nums=[0,20,0,4,31]
initLen = ①
i=0
j=0
while i < nitLen:
    if ②:
        ③ = nums[i]
        j+=1
    i+=1
④ = (len(nums)-j)*[0]
print(⑤)
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
编辑模式
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析