统计中英文字母、空格、数字和其他字符个数---小白程序

photoor 1年前 ⋅ 476 阅读

icount=input('请输入一行内容,包括,字母,数字,空格等\n') numbers=['0','1','2','3','4','5','6','7','8','9'] alphams=['a','b','c','d','e','f','g','h','i','g','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

numbersno=0 alphamno=0 spaceno=0 othersno=0

for inputdata in range(0,len(icount)): if icount[inputdata] in alphams: alphamno+=1 elif icount[inputdata] in numbers: numbersno+=1 elif icount[inputdata] ==' ': spaceno+=1 else: othersno+=1

print(alphamno,numbersno,spaceno,othersno)


全部评论: 0

    我有话说: