forked from Chubek/CodingChallenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.py
More file actions
20 lines (15 loc) · 491 Bytes
/
Program.py
File metadata and controls
20 lines (15 loc) · 491 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def compress_text(string_text):
text_dict = {}
text_split = str.split(string_text, ' ')
for index, word in enumerate(text_split):
value = 0
if word not in text_dict:
text_dict[word] = index
to_write = ''
for words in text_split:
to_write += str(text_dict[words])
to_write += ' '
file = open("file.txt", "w")
file.write(to_write)
file.close()
compress_text("hello my baby hello my honey hellow my ragtime gal")