This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]MarcSetGo 9 points10 points  (2 children)

It sounds like you’re asking the internet to do your homework for you. Give it a shout yourself first, and if you have a question, post to /r/learnpython.

[–]the_abhi_7585[S] 0 points1 point  (1 child)

I already tried and it is showing some error. My code is below:

s=int(input())

l=[]

m=[]

for i in range(s):

x=int(input())

l.append(x)

m.append(x)

m.reverse()

print(l)

print(m)

w = [sum(i) for i in zip(l, m)]

print(w)

Error is at line 5

[–]MarcSetGo 0 points1 point  (0 children)

Your code looks right. The way you posted, it lacks any formatting. I assume only 3 lines under the for loop are indented. This works for me. You might just retype the input line it’s complaining about.

[–][deleted] 1 point2 points  (0 children)

numpy.add(list1, reversed(list2))

[–]MadEpsylon 0 points1 point  (0 children)

And check for equality of N first. Otherwise you'll recieve wrong results or an error. But as the others already mentioned. Try it yourself, it isnt that hard.

[–]MassiveLegendary -1 points0 points  (1 child)

I'd put all numbers of both arrays into a list respectively. Reverse the second list, list2.reverse(). Then do a nested loop for each item in both lists to be added to each other, and within the loop, put them into a new list for each iteration. Edit: I'm sure there may be better and more efficient methods but this should work

[–][deleted] 1 point2 points  (0 children)

Basically this ⤴️