Ad
Code
Diff
  • def capitalize_sentence(sentence):
        return sentence.title()
    • def capitalize_sentence(sentence):
    • glue = ' '
    • return glue.join([i.capitalize() for i in sentence.split(' ')])
    • return sentence.title()
Code
Diff
  • def sum_list_numbers(list_numbers):
        return sum(int(n) for n in list_numbers)
    • sum_list_numbers = lambda x: reduce(lambda y, z: y + int(z), x, 0)
    • def sum_list_numbers(list_numbers):
    • return sum(int(n) for n in list_numbers)
Code
Diff
  • def count_sheeps(sheeps):
        return sum(1 for i in sheeps if i == True)
    • def count_sheeps(sheeps):
    • return str(sheeps).count('T')
    • return sum(1 for i in sheeps if i == True)
Strings
Code
Diff
  • def cake_maker(word: str) -> str:
        for l in "cake":
            if l not in word.lower():
                return "Not enough to make the cake!"
            
        return "Cake"
    • def cake_maker(word: str) -> str:
    • return 'Cake' if 'cake' == ''.join([i for i in 'cake' if i in word.lower()]) else "Not enough to make the cake!"
    • for l in "cake":
    • if l not in word.lower():
    • return "Not enough to make the cake!"
    • return "Cake"
Code
Diff
  • import random
    quotes= ["Captain Teemo on duty.","Yes, sir!", "Armed and ready.","Reporting in.","Hut, two, three, four.","I'll scout ahead!","Swiftly!","That's gotta sting.","Never underestimate the power of the Scout's code.","Size doesn't mean everything."]
    def motivation():
        return random.choice(quotes)
    • from random import randint
    • import random
    • quotes= ["Captain Teemo on duty.","Yes, sir!", "Armed and ready.","Reporting in.","Hut, two, three, four.","I'll scout ahead!","Swiftly!","That's gotta sting.","Never underestimate the power of the Scout's code.","Size doesn't mean everything."]
    • def motivation():
    • return quotes[randint(0,len(quotes)-1)]
    • return random.choice(quotes)