Please Login in order to post a comment
Python Modify string s to lower case and eliminate white space. Add to a set() that cannot have a duplicate. Compare its size
def pangrams(s): # Write your code here s = set(''.join(s.lower().split())) return 'pangram' if len(s) == 26 else 'not pangram'
Scala
def pangrams(s: String): String = { val cleansedString = s.toLowerCase().trim().distinct val cleansedAsciiArray = cleansedString.map(_.toInt).toArray val asciiArray = ('a'.toInt to 'z'.toInt).toArray val isPangram = asciiArray.intersect(cleansedAsciiArray).length == 26 if(isPangram) "pangram" else "not pangram" }
Simple for loop :
def pangrams(s): alph = "abcdefghijklmnopqrstuvwxyz" for i in alph: if i not in s.lower(): return "not pangram" return "pangram"
def pangrams(s): # Write your code here alp='abcdefghijklmnopqrstuvwxyz' l=len(set(s.lower().replace(" ",""))) # print(l) for i in alp: if i in set(s.lower().replace(" ","")) and l==26: return 'pangram' else: return 'not pangram'
Seems like cookies are disabled on this browser, please enable them to open this website
Python Modify string s to lower case and eliminate white space. Add to a set() that cannot have a duplicate. Compare its size
Scala
Simple for loop :
Write your code here
print(l)