Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # the reading part
- try:
- inFile = open("unsortedfruits.txt", 'r')
- except IOError:
- print 'Failed opening unsortedfruits.txt to read'
- fList = []
- for unsortedfruits in inFile:
- fList.append(unsortedfruits)
- fList.sort()
- inFile.close()
- # the writing part
- try:
- outFile = open("sortedfruits.txt", 'w')
- except IOError:
- print 'Failed writing into sortedfruits.txt'
- outFile.writelines(fList)
- outFile.close()
Add Comment
Please, Sign In to add comment