example-code-2e/02-array-seq/bisect_insort.py

13 lines
213 B
Python
Raw Normal View History

2014-10-14 19:26:55 +02:00
import bisect
import random
SIZE = 7
random.seed(1729)
my_list = []
for i in range(SIZE):
new_item = random.randrange(SIZE * 2)
2014-10-14 19:26:55 +02:00
bisect.insort(my_list, new_item)
2021-02-15 00:28:07 +01:00
print(f'{new_item:2d} -> {my_list}')