What is the Meaning of life?
def meaning_of_life_is():
return """
go crazy with your imagination and return anything you like.
strings, numbers, ... just don't return None.
may the most creative answer win
"""
import codewars_test as test
# TODO Write tests
from solution import meaning_of_life_is # or from solution import example
# test.assert_equals(actual, expected, [optional] message)
@test.describe("Example")
def test_group():
@test.it("test case")
def test_case():
test.assert_not_equals(meaning_of_life_is(), None)
Algorithms
Logic
make code more readable instead of a cryptic one liner
def get_nth_words(text, n): if n <= 0: return "" words = text.split() nth_words = [word for word in words[n-1 : : n]] return " ".join(nth_words)
get_nth_words=lambda s,n:""if n<=0else " ".join(s.split()[n-1::n])- def get_nth_words(text, n):
- if n <= 0:
- return ""
- words = text.split()
- nth_words = [word for word in words[n-1 : : n]]
- return " ".join(nth_words)