函数课后题求助
>>> def count(*p):length=len(p)
for i in range(length):
letters=0
space=0
digit=0
others=0
for each in p:
if each.isalpha():
letters+=1
elif each.isdight():
digit+=1
elif each ==' ':
space+=1
else:
others+=1
print('第%d个字符串共有:英文母%d个,数字%d个,空格%d个,其他字符%d.'%(i+1,letters,digit,space,others))
>>> count('sad7-')
Traceback (most recent call last):
File "<pyshell#97>", line 1, in <module>
count('sad7-')
File "<pyshell#96>", line 11, in count
elif each.isdight():
AttributeError: 'str' object has no attribute 'isdight'
求问报错原因 isdigit() 哦哦我知道了打错了{:10_260:}
页:
[1]