Reputation: 161
temp1 = []
filtered_tokens = ['once','upon','a','time','in','the','forest']
for i in range(len(filtered_tokens)):
for j in range(i+1,len(filtered_tokens)):
temp1.append(filtered_tokens[i]+' '+filtered_tokens[j])
filetered_list, in the above code contains 10,000 words, i only gave the sample list.
output needed for me: once upon, once a, once in, once the, once forest, upon a, upon time, upon in, upon the, upon forest, a time, a in, a the, a forest, time in, time the, time forest, in the, in forest, the forest
when i wrote the logic and run it, compiler thrown me Low memory exception at run time.
Please help me how i can solve this using Combinations or any other python language.
Thank You
Upvotes: 1
Views: 1535