计算概论C统计数字字符个数所属作业: hw4 算法: 循环代码11 2 3 4 5 6 cnt = 0 s = input() for x in s: if '0' <= x <= '9': cnt += 1 print(cnt) 代码21 2 3 4 5 6 s=input() count=0 for char in s: if char.isdigit(): count+=1 print(count) 找bug:1 2 3 4 5 6 7 8 word = input() sum = 0 for letter in word: for i in range(9): i = str(i) if letter == i: sum += 1 print(sum) 判断数字的方法1 2 3 4 '0' <= x <= '9' '0' <= x and x <= '9' x.isdigit() x in '0123456789' 错误写法1 2 3 4 # 错的 s = input() for x in s: if x == '0' or '1' or '2' ...