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 203 views
1 answer 227 views
227 views asked Jun 26, 2018 by avibootz
1 answer 211 views
1 answer 161 views
161 views asked May 29, 2023 by avibootz
1 answer 129 views
...