-
Description Using regexp makes it simpler
Code import re class Disemvowel: def __init__(self, s): self.s = s def scalpel(self): return re.sub(r'[AEIOU]', '', self.s, flags=re.IGNORECASE)
Test Cases import codewars_test as test from solution import Disemvowel # test.assert_equals(actual, expected, [optional] message) .describe("Example") def test_group(): .it("test case") def hi_guys(): test.assert_equals(Disemvowel("HI GUYS").scalpel(), "H GYS") test.assert_equals(Disemvowel("AEIOU").scalpel(), "") test.assert_equals(Disemvowel("Shrek is an orge").scalpel(), "Shrk s n rg") test.assert_equals(Disemvowel("Seraph is coding in Python").scalpel(), "Srph s cdng n Pythn") test.assert_equals(Disemvowel("C0ffee makes Code!").scalpel(), "C0ff mks Cd!")
Output:
-
Code - import re
- class Disemvowel:
- def __init__(self, s):
- self.s = s
- def scalpel(self):
return ("".join(x for x in self.s if x.lower() not in "aeiou"))- return re.sub(r'[AEIOU]', '', self.s, flags=re.IGNORECASE)
- 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 }}