Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #section 1
  2.  
  3. sentence = 'this is my sentence'
  4. answer = input(do you want to print your sentence? y/n)
  5. if answer == 'y' or 'yes':
  6. print(sentence)
  7.  
  8. from ast import literal_eval
  9.  
  10. with open('word_file.txt') as f:
  11. data = f.read().strip()
  12. words = ast.literal_eval(data)
  13.  
  14. with open('pos_file.txt') as f:
  15. data = f.read().strip()
  16. pos = ast.literal_eval(data)
  17.  
  18. result = " ".join([words[i-1] for i in pos])
  19.  
  20. import ast
  21.  
  22. with open('word_file.txt') as f:
  23. indivdual_words = ast.literal_eval(f.read())
  24. with open('pos_file.txt') as f:
  25. positions = ast.literal_eval(f.read())
  26.  
  27. sentence = " ".join([indivdual_words[i-1] for i in positions])
  28.  
  29. the cat sat on the cat mat
  30.  
  31. word_list = []
  32. for word in w:
  33. wordlist.append(word)
  34.  
  35. sentence = ''
  36. for index in n:
  37. word = wordlist[index]
  38. sentence+= word
  39. sentence+= ' '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement