import random def RandomDick(): with open('dicktxt\dick_sinonims.txt', 'r', encoding='utf-8') as file: words = file.readlines() random_line = random.choice(words).strip() return random_line