【问题标题】:Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. new to programming编写一个 Python 函数,它接受一个字符串并计算大写字母和小写字母的个数。编程新手
【发布时间】:2022-12-04 13:09:01
【问题描述】:

I have tried this solution. But I am not receiving any output. Can someone please point out my error.

def num_case(str):
    z=0
    j=0
    for i in str:
        if i.isupper():
            z=z+1
            return z
        elif i.islower():
            j=j+1
            return j
        else:
            pass
    
    
    
    print(\'upper case:\', z)
    print(\'lowercase:\', j)
    
num_case(\'The quick Brow Fox\')
  • remove the return statements for starters

标签: python string uppercase lowercase


【解决方案1】:
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 2020-01-04
  • 2015-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-28
  • 1970-01-01
  • 2020-08-18
相关资源
最近更新 更多