I have a scenario like this:
main = [200,300,400,500] sec = [0,0,1,0] new = []
The condition is,
output has to be like,
new = [200,500,500,900]
main = [200,300,400,500] sec = [0,0,1,0] new = [main[0]] for i in range(1, len(main)): if sec[i]: new.append(new[-1]) else: new.append(main[i] + main[i - 1]) print(new)
2.1m questions
2.1m answers
60 comments
57.0k users