2个回答
2020-04-12
展开全部
class Counts:
def __init__(self):
self.info= input('请输入字符')
self.sc=0
self.nc=0
'''
#for 遍历
'''
def check_for(self):
for i in self.info:
if i.isdigit():
self.nc=self.nc+1
if i.isalpha() and \
i==i.lower():
self.sc=self.sc+1
print(f'小写字母{self.sc}个,数字\
{self.nc}个。')
'''
while
'''
def check_while(self):
n=len(self.info)
while n>0:
n=n-1
if self.info[n].isdigit():
self.nc=self.nc+1
if self.info[n].isalpha() and \
self.info[n]==self.info[n].lower():
self.sc=self.sc+1
print(f'小写字母{self.sc}个,数字\
{self.nc}个。')
C=Counts()
C.check_for()
C1=Counts()
C1.check_while()
def __init__(self):
self.info= input('请输入字符')
self.sc=0
self.nc=0
'''
#for 遍历
'''
def check_for(self):
for i in self.info:
if i.isdigit():
self.nc=self.nc+1
if i.isalpha() and \
i==i.lower():
self.sc=self.sc+1
print(f'小写字母{self.sc}个,数字\
{self.nc}个。')
'''
while
'''
def check_while(self):
n=len(self.info)
while n>0:
n=n-1
if self.info[n].isdigit():
self.nc=self.nc+1
if self.info[n].isalpha() and \
self.info[n]==self.info[n].lower():
self.sc=self.sc+1
print(f'小写字母{self.sc}个,数字\
{self.nc}个。')
C=Counts()
C.check_for()
C1=Counts()
C1.check_while()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询