Is there a way to add a number to every single element of list in python

Submitted 5 years ago
Ticket #178
Views 415
Language/Framework Python
Priority Medium
Status Closed

l1=[20,30,10.5]

I have the following list I want the output as:

[30,40,20.5]

I want the most efficient way of answer

Submitted on Sep 28, 20
add a comment

1 Answer

Verified


l1=[20,30,10.5]
result = [item+10 for item in l1]
print(result)

this will give you desired output

Submitted 5 years ago


Latest Blogs