我需要计算用户输入的句子中大写字母的数量。
当我在 Google 上搜索解决方案时,我遇到了这个命令sum(1 for c in sentence if c.isupper()))。
sum(1 for c in sentence if c.isupper()))
我使用了它并且它有效,但我还需要向我的老师解释代码。
我该怎么做呢?
python string command python-3.x
command ×1
python ×1
python-3.x ×1
string ×1