set with len

Πανόγραμμα
Πανόγραμμα στη διαδρομή Python
def is_pangram(sentence):
    return len(set(ltr for ltr in sentence.lower() if ltr.isalpha())) == 26
  • This approach first makes a set from the lowercased characters of the sentence.
  • The characters are filtered using a set comprehension with an if isalpha() statement, so that only alphabetic characters make it into the set.
  • The function returns whether the len() of the set is 26. If the number of unique ASCII (American Standard Code for Information Interchange) letters in the set is equal to the 26 letters in the ASCII alphabet, then the function will return True.
  • This approach is efficient because it uses a set to eliminate duplicates and directly checks the length, which is a constant time operation.
Translation missing: el.number.nth.ordinalized Sep 2026 · Σου φάνηκε χρήσιμη;