0
How can I multiply each element of a list by 10
3 Antworten
+ 7
You can just use a list comprehension:
my_list = [1, 2, 3, 4, 5] my_new_list = [i * 5 for i in my_list] >>> print(my_new_list) [5, 10, 15, 20, 25]
+ 5
n=[7,5,9]
for i in range(len(n)):
n[i]=n[i]*10
print(n[i])
#Like this you can
+ 4
Another way by using map
my_list = [1, 2, 3, 4, 5]
print (list(map(lambda x:x*10,my_list )))
#output [10,20,30,40,50]