Write a Python function to check whether a string is pangram or not. (Assume the string passed in does not have any punctuation)
时间: 2024-10-13 11:03:25 浏览: 23
Average-is-not-Fast-Enough.rar_The First_distance relay
当然可以,首先你需要了解什么是帕格拉姆(Pangram),它是指包含英语字母表所有26个字母的句子或短语。下面是一个简单的Python函数,用于检查给定字符串是否为帕格拉姆:
```python
def is_pangram(s):
alphabet = "abcdefghijklmnopqrstuvwxyz"
for char in alphabet:
if char not in s.lower():
return False
return True
# 测试示例
s = "The quick brown fox jumps over the lazy dog"
if is_pangram(s):
print(f"{s} is a pangram.")
else:
print(f"{s} is not a pangram.")
# 使用这个函数检查输入的字符串是否为帕格拉姆
input_string = input("Enter a string without punctuation: ")
if is_pangram(input_string):
print("The string is a pangram.")
else:
print("The string is not a pangram.")
阅读全文