在Python中检查给定字符串是否为大写字母的程序
假设我们有一个字符串s,它表示一个句子,我们必须检查英语字母的每个字母是否至少使用一次。
因此,如果输入就像“脾气暴躁的巫师为邪恶的女王和杰克制造有毒的啤酒”,那么输出将为True
为了解决这个问题,我们将遵循以下步骤-
s:=将s的所有字母转换成小写字母
a:=0
对于每个英文字母i,
返回False
如果我不在s,则
返回True
让我们看下面的实现以更好地理解-
示例
import string
class Solution:
def solve(self, s):
s=s.lower()
a=0
for i in string.ascii_lowercase :
if i not in s :
return False
return True
s = "The grumpy wizards make toxic brew, for the evil queen and Jack"
ob = Solution()
print(ob.solve(s))输入值
"The grumpy wizards make toxic brew, for the evil queen and Jack"
输出结果
True
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短