cat src.txt
a
b
c
ab
abc
tty
t
tt
bcd
bc
abcde
abcd
cat prefix.py
file = open('/home/bin/src.txt')
wlist = file.readlines()wsrc = []
for key in wlist:
key = key[0:-1]
wsrc.append(key)
print wsrc
result = []
for word in wsrc:
if len(word) > 1:
tmp = ''
for i in range(len(word)-1):
letter = word[0:i+1]
if letter in wsrc:
tmp += (letter+'-')
tmp += word
result.append(tmp)
print result