Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import List
- # Zadanie 3 - po bólach
- def flat_list(list_in: List):
- list_out = []
- for lists in list_in:
- if type(lists) is list:
- for number in lists:
- list_out.append(number)
- else:
- list_out.append(lists)
- return list_out
- def explode_list(li_in: List):
- for element in li_in:
- if type(element) is list:
- explode_list(li_in=element)
- else:
- print(element, end=' ')
- # def recursion_infinite():
- # recursion_infinite()
- #
- # recursion_infinite()
- test_list_1 = [1, 2, [2, 3, 2], [11, 10]]
- test_list_2 = [1, 2, [2, 3, 2], [[1, 2], [2, 4, 5]]]
- print(flat_list(test_list_1))
- explode_list(test_list_1)
- print(flat_list(test_list_2))
- explode_list(test_list_2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement