how to operate on all elements in a list python

Solutions on MaxInterview for how to operate on all elements in a list python by the best coders in the world

showing results for - "how to operate on all elements in a list python"
Line
07 Feb 2016
1oldlist = [1,2,3]
2newlist = [i * 2 for i in oldlist]
3print(newlist)
4# >>> [2, 4, 6]