鱼C论坛

 找回密码
 立即注册
查看: 1100|回复: 3

[已解决]python零基础入门19课课后题求助=-=

[复制链接]
发表于 2020-4-19 23:41:06 | 显示全部楼层
转义符不会算进去,你的代码错了一个地方,input收集参数看下方:
  1. def count(*strr):#收集参数
  2.     length=len(strr)
  3.     for i in range(length):
  4.         abcs=0
  5.         nums=0
  6.         spaces=0
  7.         elsestrs=0
  8.         for each in strr[i]:      #你的代码这里错了
  9.             if each.isalpha():
  10.                 abcs+=1
  11.             elif each.isdigit():
  12.                 nums+=1
  13.             elif each==' ':
  14.                 spaces+=1
  15.             else:
  16.                 elsestrs+=1
  17.         print('第%d个字符串共有英文字母%d个,数字%d个,空格%d个,其他字符%d个。'%(i+1,abcs,nums,spaces,elsestrs))
  18.         
  19. count(input())     #这样收集参数?
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-31 04:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表