Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. words = r"C:usersCecewords.txt"
  2.  
  3. lines = [line.rstrip('n') for line in open(words)]
  4. wordsC = lines
  5. randword = random.choice(wordsC)
  6.  
  7.  
  8. while randword == 5:
  9. if len(randword) == 5:
  10. word = randword.upper()
  11. myword = list(word)
  12. else:
  13. pass
  14.  
  15. with open(r"C:usersCecewords.txt") as f:
  16. words_5 = []
  17. for line in f:
  18. word = line.strip()
  19. if len(word) == 5:
  20. words_5.append(word.upper())
  21.  
  22. lines = [line.rstrip('n') for line in open(words) if len(line.rstrip('n')) == 5]
  23.  
  24. randword = random.choice(wordsC)
  25.  
  26. randword = random.choice(wordsC)
  27.  
  28. while len(randword) != 5:
  29. randword = random.choice(wordsC)
  30. word = randword.upper()
  31. myword = list(word)
  32.  
  33. import random
  34.  
  35. def take_random_5(l):
  36. randword = random.choice(l)
  37. if len(randword) != 5:
  38. return
  39. return randword
  40.  
  41. words = r"C:usersCecewords.txt"
  42. lines = [line.rstrip('n') for line in open(words)]
  43. while True:
  44. take_random_5(lines)
  45.  
  46. import random
  47. filename = r"C:usersCecewords.txt"
  48. with open(filename) as f:
  49. content = f.readlines()
  50. # you may also want to remove whitespace characters like `n` at the end of each line
  51. content = [x.strip() for x in content]
  52. words5 = []
  53. for x in content:
  54. if len(x) == 5:
  55. words5.extend(x)
  56. print(random.choice(words5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement