初级
统计字符
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve(s):
english = sum(1 for c in s if c.isalpha())
space = sum(1 for c in s if c == ' ')
digit = sum(1 for c in s if c.isdigit())
other = len(s) - english - space - digit
print(english)
print(space)
print(digit)
print(other)
示例
输入
solve('Hello World 123!')
期望输出
10 2 3 1
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199