# Serence

We always need to recite something. But directly looking at the words with the definition nearby is not a good way to recite. Thus, I write this program to randomly assign the order of the words and put the definition of each word at the bottom of the file to help us recite easier.

'''
Before useing this program, please make sure you have put the source.txt in the folder.
At the same time, please make sure the txt file that you want to randomly assign have adjusted to this format:
text (symbol like -) explanation

Results will be output in the result.txt.
If you want to split the work and sentence independently, you can place a symbol you choose at the first line of source.txt. If there is not any symbol at the first line, the program will automatically use - as a symbol to split the text. [The symbol must only have length 1]
'''

import random

file = open("source.txt", "r")
sym = text[0]
flag = 0
re = []
ans = []

if len(sym) > 1:
sym = "-"
else:
flag = 1

dic = {}

for i in range(flag,len(text)):
temp = text[i]
words = temp.split(sym)
for i in range(0,2):
words[i] = words[i].strip()
dic[words[0]] = words[1]
re.append(words[0])

random.shuffle(re)

fwrite = open("result.txt","w")

for i in range(0,len(re)):
fwrite.write(str(re[i])+"\n")

for i in range(0,8):
fwrite.write("\n")