检查字符串是否是 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 简短的祝福语12字
14 5岁宝宝祝福语简短
15 Q穷人结婚祝福语简短
16 婆婆生日祝福语短语简短
17 公司上班祝福语大全简短
18 写给男生简短的祝福语