def count_letters(string): uppercase_count = 0 lowercase_count = 0 for char in string: if char.isupper(): uppercase_count += 1 elif char.islower(): lowercase_count += 1 return uppercase_count, lowercase_count

q5

a5 = count_letters('Hello World')[0]

q6

a6 = count_letters('Hello World')[1]

q7

a7 = count_letters('wa#uD!Ah+fHcUSjPls')[0]

q8

a8 = count_letters('wa#uD!Ah+fHcUSjPls')[1]

q9

a9 = count_letters('qwe@1iwOhdsaQKds2a0ODlasdaASa')[0]

q10

a10 = count_letters('qwe@1iwOhdsaQKds2a0ODlasdaASa')[1

编写一个函数实现计算大小写字母的个数q5、计算Hello World这一字符串中大写字母个数有多少?将结果保存到a5中;q6、计算Hello World这一字符串中小写字母的个数有多少?将结果保存到a6中;q7、计算wa#uD!Ah+fHcUSjPls这一字符串中大写字母的个数有多少?将结果保存到a7中;q8、计算wa#uD!Ah+fHcUSjPls这一字符串中小写字母的个数有多少?将结果保存到a

原文地址: https://www.cveoy.top/t/topic/ipJy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录