i have a list that looks like this:
list = [1,2,3,4]
I would like to add 12 to each value. In PHP you can use array_walk to process each item in the array. Is there a similar function or easier way than doing a for loop such as:
for i in list:
Thanks
Use list comprehensions. Try this:
list = [i+12 for i in list]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With