I know we get to return only one time but is it possible to increment all elements of a list at once.
I know I can do this
def test(lst, increment):
newlst = []
for value in lst:
newlst.append(value + increment)
return newlst
print(test([1,2],1))
OutPut = [2, 3]
I feel like the above code is little more work Is it possible to return all incremented values?
def test(lst, increment):
for value in lst:
return value + increment
print(test([1,2],1))
OutPut = 2, 3