sentence = raw_input("Enter a sentence: ")
sentence = sentence.lower().split()
uniquewords = []
for word in sentence:
if word not in uniquewords:
uniquewords.append(word)
positions = [uniquewords.index(word) for word in sentence]
recreated = " ".join([uniquewords[word] for word in positions])
positions = [x+1 for x in positions]
print uniquewords
print positions
print recreated
file = open('task2file1.txt', 'w')
file.write('\n'.join(uniquewords))
file.close()
file = open('task2file2.txt', 'w')
file.write('\n'.join(positions))
file.close()
This is the code I have so far and everything works except saving the positions into a textfile, the error message I get is
"file.write('\n'.join(positions))
TypeError: sequence item 0: expected string, int found"