Pangrams [Hacker Rank]

Kim Hayeon·2023년 4월 26일
0

Algorithm Study

목록 보기
13/37
post-thumbnail

Question

A pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not pangram as appropriate.

Function Description

Complete the function pangrams in the editor below. It should return the string pangram if the input string is a pangram. Otherwise, it should return not pangram.

pangrams has the following parameter(s):

  • string s: a string to test

Returns

  • string: either pangram or not pangram

Code

def pangrams(s):
    # Write your code here
    s = s.replace(" ", "").lower()
    lst = []
    for i in s:
        if i not in lst:
            lst.append(i)

    if len(lst) == 26:
        return 'pangram'
    else:
        return 'not pangram'
profile
우리는 무엇이든 될 수 있어

0개의 댓글