diff --git a/practica/stepik/stepik_tasks/sum_num_nearby.py b/practica/stepik/stepik_tasks/sum_num_nearby.py index caa0217..a1b551d 100644 --- a/practica/stepik/stepik_tasks/sum_num_nearby.py +++ b/practica/stepik/stepik_tasks/sum_num_nearby.py @@ -1,3 +1,4 @@ +# вариант решения 1 a = input().split() len_a = len(a) - 1 for index, number in enumerate(a): @@ -19,3 +20,17 @@ for index, number in enumerate(a): b += " " + str(S2) print (b) + +# вариант решения 2 -короче +initial_list = input().split() +sum_list = [] +left_index = -1 +right_index = -len(initial_list) + 1 +middle_index = 0 +while middle_index < len(initial_list): + sum_list.append(initial_list[left_index] + initial_list[right_index]) + left_index += 1 + right_index += 1 + middle_index += 1 +print(sum_list) + \ No newline at end of file