| Total Complexity | 2 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | def split_list(items: list) -> list: |
||
| 2 | length = len(items) |
||
| 3 | if length % 2: |
||
| 4 | return [items[:length // 2 + 1], items[length // 2 + 1:]] |
||
| 5 | else: |
||
| 6 | return [items[:length // 2], items[length // 2:]] |
||
| 7 | |||
| 8 | |||
| 9 | if __name__ == '__main__': |
||
| 10 | print("Example:") |
||
| 11 | print(split_list([1, 2, 3, 4, 5, 6])) |
||
| 12 | |||
| 13 | # These "asserts" are used for self-checking and not for an auto-testing |
||
| 14 | assert split_list([1, 2, 3, 4, 5, 6]) == [[1, 2, 3], [4, 5, 6]] |
||
| 15 | assert split_list([1, 2, 3]) == [[1, 2], [3]] |
||
| 16 | assert split_list([1, 2, 3, 4, 5]) == [[1, 2, 3], [4, 5]] |
||
| 17 | assert split_list([1]) == [[1], []] |
||
| 18 | assert split_list([]) == [[], []] |
||
| 19 | print("Coding complete? Click 'Check' to earn cool rewards!") |
||
| 20 |