isnt there any way to apply the for loop on each item of the list WHILE KEEPING THEM IN THE SAME LIST. ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

isnt there any way to apply the for loop on each item of the list WHILE KEEPING THEM IN THE SAME LIST. ?

12th Aug 2016, 11:45 AM
Shoaib Azam
Shoaib Azam - avatar
4 Answers
+ 1
need more details about what exactly you're trying to do
12th Aug 2016, 12:27 PM
Eric Reed
Eric Reed - avatar
0
suppose a list(range(5)) . i want to multiply each by 2. but they should remain in list form. like [0,2,4,6,8]. shall be grateful.
12th Aug 2016, 12:30 PM
Shoaib Azam
Shoaib Azam - avatar
0
aaaaAas
12th Aug 2016, 3:54 PM
johann
0
print(list("".join([str(x*2) for x in range(5)])))
13th Aug 2016, 2:50 AM
Shekhar Nadar
Shekhar Nadar - avatar