检查字符串是否是 Python 中的 Pangrammatic Lipogram
假设我们得到了三个字符串,我们被要求找出哪些字符串是Pangram、Lipogram和PangrammaticLipogram。Pangram是一个字符串或一个句子,其中字母表中的每个字母至少出现一次。Lipogram是一个字符串或一个句子,其中没有出现字母表中的一个或多个字母。PangrammaticLipogram是一个字符串或句子,其中除了一个字母外,字母表中的所有字母都出现了。
所以,如果输入是这样的-
pack my box with five dozen liquor jugs to stay in this mortal world or by my own hand go to oblivion, that is my conundrum. the quick brown fox jumps over a lazy dog waltz, nymph, for quick jigs ve bud,
那么输出将是-
The String is a Pangram The String isn't a Pangram but might be a Lipogram The String is a Pangram The String is a Pangrammatic Lipogram
示例
让我们看看以下实现以获得更好的理解-
import string
def solve(input_string):
input_string.lower()
i = 0
for character in string.ascii_lowercase:
if(input_string.find(character) < 0):
i += 1
if(i == 0):
output = "The String is a Pangram"
elif(i == 1):
output = "The String is a Pangrammatic Lipogram"
else:
output = "The String isn't a Pangram but might be a Lipogram"
return output
print(solve("pack my box with five dozen liquor jugs"))
print(solve("to stay in this mortal world or by my own hand go to oblivion,that is my conundrum."))
print(solve("the quick brown fox jumps over a lazy dog"))
print(solve("waltz, nymph, for quick jigs ve bud"))输入
pack my box with five dozen liquor jugs to stay in this mortal world or by my own hand go to oblivion, that is my conundrum. the quick brown fox jumps over a lazy dog waltz, nymph, for quick jigs ve bud输出结果
The String is a Pangram The String isn't a Pangram but might be a Lipogram The String is a Pangram The String is a Pangrammatic Lipogram
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短