下列 Python 代码用于计算从 1 到 N(含 N)的所有正整数中,数字 3 出现的总次数。当N = 40时,共有

14个3,包括3、13、23、30-39,其中33计两次,共计14个3。将代码while i != 0改为while i执行结果相同。(

)

N = int(input("请输入正整数N:"))cnt = 0 #保存3的个数for i in range(1, N + 1):    while i != 0:        if i % 10 == 3:            cnt += 1        i //= 10print(cnt)
填写答案