본문 바로가기
Python

pangram 판별

by shur_ 2023. 11. 11.
import sys

alphabet_set = set('abcdefghijklmnopqrstuvwxyz')

pangram = sys.stdin.readline()
pangram_set = set(pangram.lower())

if alphabet_set.issubset(pangram_set):
    print("YES")
else:
    print("NO")

 

set, issubset 사용.

예를 들어, A와 B가 집합일 때, A.issubset(B)는 A가 B의 부분집합인지를 검사. 만약 A가 B의 부분집합이라면 True를 반환하고, 그렇지 않으면 False를 반환.

'Python' 카테고리의 다른 글

ss  (0) 2024.02.06
[Python] 아스키 코드, ASCII Code  (1) 2023.12.08
[Python] 파이썬 리스트 비어있는지 여부 확인  (0) 2023.09.05
[Python] 10진수 2진수, 8진수, 16진수 변환  (0) 2023.08.25
파이썬 map 함수  (0) 2022.11.22

댓글