
对字符串相关内容不熟悉,想知道里面的要求要用什么语句来满足,诚恳求学,希望能够解答
关注
def count(s):
alpha,num,space,other=0,0,0,0
for i in s:
if i.isalpha():
alpha+=1
elif i.isdigit():
num+=1
elif i.isspace():
space+=1
else:
other+=1
print('英文字符数{},数字字符数{},空格字符数{},其他字符数{}'.format(alpha,num,space,other))
if alpha==len(s):
return 1
return 0
t=0
l=[]
for i in range(10):
s=input("请输入一个字符串:")
l.append(s)
t+=count(s)
if t==10:
for i in l:
print(i.upper ())
else:
print('不存在单纯字母字符串')