If I have list=[1,2,3] and I want to add 1 to each element to get the output [2,3,4], how would I do that?
list=[1,2,3]
1
[2,3,4]
I assume I would use a for loop but not sure exactly how.
new_list = [x+1 for x in my_list]
1.4m articles
1.4m replys
5 comments
57.0k users