Strings
Data Types
Arrays
Split the given string to get all alphabets present in the string. The string might contain characters apart from digits and alphabets, such as #, @ and others.
Example 1
Input : "Hello"
Ouput : ['H', 'e', 'l', 'l', 'o']
Example 2
Input : "Hello World!"
Ouput : ['H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd']
def Special_Fission(input): input = list(input) return list(filter(lambda x:x.isalpha(),input))
split = list- def Special_Fission(input):
- input = list(input)
- return list(filter(lambda x:x.isalpha(),input))
import codewars_test as test @test.describe("Example 1") def test_group(): @test.it("test case") def test_case(): test.assert_equals(Special_Fission('Hello'), ['H', 'e', 'l', 'l', 'o']) @test.describe("Example 2") def test_group(): @test.it("test case 2") def test_case(): test.assert_equals(Special_Fission('Hello World!'), ['H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd']) @test.describe("Example 3") def test_group(): @test.it("test case 3") def test_case(): test.assert_equals(Special_Fission('!!!!'), []) @test.describe("Example 4") def test_group(): @test.it("test case 4") def test_case(): test.assert_equals(Special_Fission(''), [])
- import codewars_test as test
import solution # or from solution import example@test.describe("Example")- @test.describe("Example 1")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(split('spam'), ['s', 'p', 'a', 'm'])- test.assert_equals(Special_Fission('Hello'), ['H', 'e', 'l', 'l', 'o'])
- @test.describe("Example 2")
- def test_group():
- @test.it("test case 2")
- def test_case():
- test.assert_equals(Special_Fission('Hello World!'), ['H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd'])
- @test.describe("Example 3")
- def test_group():
- @test.it("test case 3")
- def test_case():
- test.assert_equals(Special_Fission('!!!!'), [])
- @test.describe("Example 4")
- def test_group():
- @test.it("test case 4")
- def test_case():
- test.assert_equals(Special_Fission(''), [])