-
Code clean=lambda s:__import__("re").sub("[0-9]","",s)
Test Cases import codewars_test as test from solution import clean import random as rand import string as s .describe("Test cases") def test_group(): .it("Fixed test cases") def fixed(): test.assert_equals(clean("2 plus 2 is 4"), " plus is ") test.assert_equals(clean("0123456789"), "") test.assert_equals(clean("3h9fk37cf"), "hfkcf") .it("Random test cases") def random(): def sol(str): return "".join("" if x.isdigit() else x for x in str) for i in range(20): bla = s.ascii_letters + s.digits bleh = [x for x in bla] rand.shuffle(bleh) bleh = "".join(bleh) print("asserting for string " + bleh) test.assert_equals(clean(bleh), sol(bleh))
Output:
-
Code clean = lambda s: ''.join(x for x in s if not x.isdigit())- clean=lambda s:__import__("re").sub("[0-9]","",s)
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}