Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. >>> # Write a program that reads words.txt and prints only the words with
  2. # more than 20 characters (not counting whitespace).
  3. # Current Status: Complete
  4. with open('words.txt', 'r') as fd:
  5. wordList = fd.read().split()
  6. print [word for word in wordList if len(word) > 20]
  7. ##################################################################################
  8. #my first solution
  9. fin = open('words.txt')
  10. t = fin.read().split('\n')
  11. for i in range(0,len(t)):
  12. if len(t[i])>5 and len(t[i])<10 :
  13. print t[i]
  14. fin.close()
  15.  
  16. ['counterdemonstrations', 'hyperaggressivenesses', 'microminiaturizations']
  17. aahing
  18. aaliis
  19. aardvark
  20. aardvarks
  21. aardwolf
  22. aasvogel
  23. aasvogels
  24. abacas
  25. abacus
  26. abacuses
  27. abakas
  28. abalone
  29. abalones
  30. abampere
  31. abamperes
  32. abamps
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement