uaveiro-leci/1ano/fp/aula09/binarySearch.py

11 lines
280 B
Python

import bisect
with open("wordlist.txt", "r") as f:
word_list: list[str] = f.read().split()
begin_index: int = bisect.bisect_left(word_list, "ea")
end_index: int = bisect.bisect_left(word_list, "eb")
print(f"Words started with 'ea': {end_index - begin_index}")