def converter(n): return dict(enumerate(("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"))).get(n)
def converter(number):try:return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"][number]except IndexError:return None- def converter(n):
- return dict(enumerate(("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"))).get(n)
import codewars_test as test # TODO Write tests import solution # 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_equals(solution.converter(0), "zero") test.assert_equals(solution.converter(5), "five") test.assert_equals(solution.converter(15), None)
- import codewars_test as test
- # TODO Write tests
- import solution # 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_equals(solution.converter(0), "zero")
- test.assert_equals(solution.converter(5), "five")
- test.assert_equals(solution.converter(15), None)