Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. def uniqueWords(inFile,outFile):
  2. inf = open(inFile,'r')
  3. outf = open(outFile,'w')
  4. for line in inf:
  5. wordlst = line.split()
  6. count = len(wordlst)
  7. outf.write(str(count)+'n')
  8.  
  9. inf.close()
  10. outf.close()
  11. uniqueWords('turn.txt','turnout.txt')
  12.  
  13. def uniqueWords(inFile,outFile):
  14. inf = open(inFile,'r')
  15. outf = open(outFile,'w')
  16. unique = []
  17. for line in inf:
  18. wordlst = line.split()
  19. for word in wordlst:
  20. if word not in unique:
  21. unique.append(word)
  22. outf.write(str(len(unique)))
  23.  
  24. inf.close()
  25. outf.close()
  26. uniqueWords('turn.txt','turnout.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement