This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from timeit import default_timer as time | |
# Open text file and add each word to a list | |
with open('file.txt') as f: | |
lines = [line.strip() for line in f] | |
words = [] | |
for l in lines: | |
words.extend(l.split()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from time import time | |
def random_string(length=20): | |
chars = string.ascii_letters | |
return ''.join(random.choice(chars) for i in range(length)) | |