def disemvowel(string_): vowels = {"a", "e", "i", "o", "u", "A", "E", "I", "O", "U"} return ''.join(char for char in string_ if char not in vowels)
- def disemvowel(string_):
list_of_oo = ["a", "e", "i", "o", "u", "O" ,"A" ,"E" ,"I"]newset = ""n = 0while n < len(list_of_oo):for i in string_:if list_of_oo[n] == i:string_ = string_.replace(i , "-")print(list_of_oo[n])n += 1return string_- vowels = {"a", "e", "i", "o", "u", "A", "E", "I", "O", "U"}
- return ''.join(char for char in string_ if char not in vowels)
import codewars_test as test from solution import disemvowel @test.describe("Disemvowel") def test_group(): @test.it("removes vowels from a string") def test_case1(): test.assert_equals(disemvowel("hello"), "hll") test.assert_equals(disemvowel("world"), "wrld") test.assert_equals(disemvowel("apple"), "ppl") @test.it("handles uppercase and lowercase vowels") def test_case2(): test.assert_equals(disemvowel("Hello World"), "Hll Wrld") test.assert_equals(disemvowel("aEiOu"), "") @test.it("handles strings with no vowels") def test_case3(): test.assert_equals(disemvowel("nthng hr"), "nthng hr") test.assert_equals(disemvowel("bcdfghjklmnpqrstvwxyz"), "bcdfghjklmnpqrstvwxyz") @test.it("handles empty string") def test_case4(): test.assert_equals(disemvowel(""), "") @test.it("handles strings with only vowels") def test_case5(): test.assert_equals(disemvowel("aeiouAEIOU"), "") @test.it("handles strings with special characters") def test_case6(): test.assert_equals(disemvowel("Shrek is an orge!"), "Shrk s n rg!") test.assert_equals(disemvowel("The quick brown fox jumps over the lazy dog."), "Th qck brwn fx jmps vr th lzy dg.")
- import codewars_test as test
- from solution import disemvowel
- @test.describe("Disemvowel")
- def test_group():
- @test.it("removes vowels from a string")
- def test_case1():
- test.assert_equals(disemvowel("hello"), "hll")
- test.assert_equals(disemvowel("world"), "wrld")
- test.assert_equals(disemvowel("apple"), "ppl")
- @test.it("handles uppercase and lowercase vowels")
- def test_case2():
- test.assert_equals(disemvowel("Hello World"), "Hll Wrld")
- test.assert_equals(disemvowel("aEiOu"), "")
- @test.it("handles strings with no vowels")
- def test_case3():
- test.assert_equals(disemvowel("nthng hr"), "nthng hr")
- test.assert_equals(disemvowel("bcdfghjklmnpqrstvwxyz"), "bcdfghjklmnpqrstvwxyz")
- @test.it("handles empty string")
- def test_case4():
- test.assert_equals(disemvowel(""), "")
- @test.it("handles strings with only vowels")
- def test_case5():
- test.assert_equals(disemvowel("aeiouAEIOU"), "")
- @test.it("handles strings with special characters")
- def test_case6():
- test.assert_equals(disemvowel("Shrek is an orge!"), "Shrk s n rg!")
- test.assert_equals(disemvowel("The quick brown fox jumps over the lazy dog."), "Th qck brwn fx jmps vr th lzy dg.")