a=[1,2,3,4,5,6,7,8,9,9,1,5,4,32,2]
a=map(lambda x :x*10,a)
print(a)
I used the Lambda function to do the things on the list at once *10.
But if you don't put a list,
map object at 0x000002659B33DF10
Is that what it says?
I wonder what that result without a list means. Is it like a hexadecimal position??
Thank you for your reply. Have a great day!
python lambda list
Try running the example below in the idle line by line. It's better to run on a computer that doesn't perform well.
>>> a = list(range(1000000))
>>> b = map(lambda x: x*10, a)
>>> c = list(b)
>>> a = list(range(100000000))
>>> b = map(lambda x: x*10, a)
>>> c = list(b)
>>> import time
>>> def func():
t = time.time()
a = list(range(100000000))
print(f"assigning a (list) took {time.time()-t} sec")
t = time.time()
b = map(lambda x: x*10, a)
print(f"assigning b (map) took {time.time()-t} sec")
t = time.time()
c = list(map(lambda x: x*10, b))
print(f"assigning c (list of map) took {time.time()-t} sec")
>>> func()
assigning a (list) took 5.798054933547974 sec
assigning b (map) took 0.0 sec
assigning c (list of map) took 34.67618656158447 sec
>>>
© 2024 OneMinuteCode. All rights reserved.