Jan-16-2017, 07:03 PM
I'm currently making a program which will compress a user sentence into two variables unique_words and positions. Unique words will be all the unique words from the users sentence, so for example "the cat sat on the mat" the unique words will be "the, cat, sat, on, mat" and the positions will be 123415. I'm saving both of these in a text file.
Then what I want to be able to do is extract these back from the text file, and store them in two separate variables, so for example I want my code to look something like so.
Then what I want to be able to do is extract these back from the text file, and store them in two separate variables, so for example I want my code to look something like so.
list_1 = [the, cat, sat, on, mat] list_2 = [1, 2, 3, 4, 1, 5] list_3 = [] for i in list_2: list_3.append(list_1[i])This is what I want to do in the end, but I am clueless as to how to extract the positions and unique_words, and store them in two separate variables!