How to measure the time of creating a list with for loop in Python

1 Answer

0 votes
from time import process_time

start = process_time()

lst = [i for i in range(100000)]

end = process_time()

print(end - start)


 
 
 
 
'''
run:

0.009295050000000003

'''


 



answered Mar 3, 2023 by avibootz

Related questions

1 answer 280 views
1 answer 305 views
305 views asked Jun 26, 2018 by avibootz
1 answer 290 views
1 answer 255 views
255 views asked May 29, 2023 by avibootz
1 answer 210 views
...