kyu_5.flatten package
Submodules
kyu_5.flatten.flatten module
Solution for -> flatten().
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.flatten.flatten.flatten(*args) list[source]
Flatten function.
The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result. :return:
kyu_5.flatten.test_flatten module
Test for -> flatten().
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.flatten.test_flatten.FlattenTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting flatten function.
- _classSetupFailed = False
- _class_cleanups = []
- test_flatten()[source]
Testing flatten function with various test data.
For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result.
The following are examples of how this function would be used and what the expected results would be:
flatten(1, [2, 3], 4, 5, [6, [7]]) # returns [1, 2, 3, 4, 5, 6, 7] flatten(‘a’, [‘b’, 2], 3, None, [[4], [‘c’]]) # returns [‘a’, ‘b’, 2, 3, None, 4, ‘c’] :return:
Module contents
Flatten.