检查字符串是否是 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 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短