Ответ:
fin = open('input.txt', 'r', encoding='utf8')
f_out = open('output.txt', 'w', encoding='utf8')
lines = []
for line in fin:
lines.append(line.strip().split())
al = []
for el in lines:
el = list(el)
for i in el:
al.append(i)
al = set(al)
for i in al:
f_out.write(str(i) + ' ')
fin.close()
f_out.close()
Объяснение:
вроде так