Advertisement
Guest User

Stepik task

a guest
May 8th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = [int(i) for i in input().split()]
  2. y = 0
  3. c = 1
  4. b = []
  5. for a[y] in a:
  6.     if y == 0:
  7.         sum1 = a[y + 1] + a[-y]
  8.         b.insert(0, sum1)
  9.     elif y == len(a):
  10.         sum2 = a[y - 1] + a[0]
  11.         b.insert(-1, sum2)
  12.     else:
  13.         while y < len(a):
  14.             sum = a[y - 1] + a[y + 1]
  15.             b.insert(c, sum)
  16.             с += 1
  17.             y += 1
  18. print(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement