分类统计字符
分類統計字符
????????????????????????????????????????????????????????????????????????????????????????????????
描述
用戶輸入一個字符串,分別統計其中小寫字母、大寫字母、數字、空格和其他字符的個數,并在一行內輸出小寫字母、大寫字母、數字、空格和其他字符的個數。
????????????????????????????????????????????????????????????????????????????????????????????????
輸入格式
輸入一個字符串????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????
輸出格式
在一行內輸出小寫字母、大寫字母、數字、空格和其他字符的個數????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????
輸入輸出示例
????????????????????????????????????????????????????????????????????????????????????????????????
輸入
Aa787ghWRD u !#$輸出
4 4 3 2 3代碼:
str = input() upper = 0 lower = 0 digit = 0 space = 0 other = 0 for i in str:if i.islower():lower = lower + 1elif i.isupper():upper = upper + 1elif i.isnumeric():digit = digit + 1elif i.isspace():space =space + 1else:other = other + 1 print(lower,upper,digit,space,other)總結
- 上一篇: ibm怎么使用u启动不了 IBM电脑无法
- 下一篇: 硬盘重新分区怎么引导 硬盘重分区引导方法