import pickle`f=open('/home/nikan/Desktop/Linux os/text/word.txt', 'rb')
pickle.load(f)`
import pickle`f=open('/home/nikan/Desktop/Linux os/text/word.txt', 'rb')
pickle.load(f)`
The problem was that only a single word was inputted and the sort method has been invoked on it.
Let's get multiple words, append them to a list and sort them:
input_words = []
# Get input words
word = input('Please enter word\n')
# As long as word is not "stop"
while word != 'stop':
# Get new input word
input_words.append(word)
# Append to list of words
word = input('Please enter word\n')
# Sort words
input_words.sort()
# Print sorted list of words
print(input_words)
# Write to file
with open('your_file.txt', 'w') as f:
for item in input_words:
f.write("%s\n" % item)