Clever_Sparkle

Select all 5 letters words

Jan 31st, 2022
1,522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. output_file = open("output1.txt", "w")
  2.  
  3. with open("words_466000.txt", "r") as input_file:
  4.     words_count = 0.
  5.     iter_counter = 0.
  6.     not_alpha = 0
  7.     for text_line in input_file:
  8.         if iter_counter >= 10**8:
  9.             break
  10.         else:
  11.             iter_counter += 1
  12.             if len(text_line) == 6: #12345\n
  13.                 if text_line[:-1].isalpha(): #12345
  14.                     words_count += 1
  15.                     output_file.write(text_line.lower() + '\n')
  16. print "words_count: ", words_count
  17. print "iter_counter: ", iter_counter
  18. print "percent of all words: ", words_count / iter_counter
Advertisement
Add Comment
Please, Sign In to add comment