diff --git a/1.14/distribute.py b/1.14/distribute.py new file mode 100644 index 0000000..bec50bb --- /dev/null +++ b/1.14/distribute.py @@ -0,0 +1,22 @@ +""" +Exercise 1.14 - Duplicate List and Distribute Values to Sublists +""" + + +# Copyright (c) 2021. Pascal Syma. All rights reserved. + +def distribute(my_item, my_list): + """ + Add _my_item_ to each row of _my_list_. + :param my_item: Item to add + :param my_list: Nested list + :return: Appended nested list + """ + return [row + [my_item] for row in my_list] + + +if __name__ == '__main__': + old_list = [['kangar'], ['z'], ['f']] + print(f'{old_list = }') + print(f'{distribute("oo", old_list) = }') + print(f'{old_list = }')