script1AM.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import random
  4. occurences = ["What are the demands","There are no demands","The demands","Impossible demands", "Impossible demand","We demand the impossible","Impossible to demand"]
  5. democracy = "democracy"
  6. democracy_en_grand = democracy.upper()
  7. print(democracy_en_grand)
  8. liste = list( democracy )
  9. random.shuffle( liste )
  10. democracy_shuffled = ''.join( liste )
  11. print(democracy_shuffled)
  12. # read stopwords from file & save them in a list
  13. # read from file
  14. with open("occupy.txt", "r") as source:
  15. txt = source.readline()
  16. print(txt)
  17. newtxt = txt.replace(democracy, democracy_shuffled)
  18. print(newtxt)
  19. # # for each line
  20. # for line in source:
  21. # # clean returns
  22. # line = line.strip()
  23. # #print(line)
  24. # #split sentences into words
  25. # words = line.split()
  26. # print(" ".join(words))
  27. # #for each words ...
  28. # for word in words:
  29. # if word == "democracy":
  30. # word = word.upper()
  31. # print(word)
  32. # liste = list( word )
  33. # random.shuffle( liste )
  34. # word = ''.join( liste )
  35. # print(word)
  36. # print(" ".join(words))
  37. # #replace what are the demands
  38. # sentence = occurences[0]
  39. # print("sentence:", sentence)
  40. # sentence.replace("What are the demands"," what are the demands ")
  41. # print(sentence)
  42. # #replace there are no demands
  43. # #sentence.replace("there are no demands","therearenodemands")
  44. # #print(sentence)
  45. # #reverse order
  46. # #chaine = "impossible demands, impossible demand, impossible to demand"
  47. # #chaine = chaine [::-1]
  48. # #print(chaine)
  49. # # majuscule
  50. # #if sentence == "We demand the impossible":
  51. # #sentence = sentence.upper()
  52. # # écrire la nouvelle liste comme chaîne de caractères dans un fichier texte
  53. # with open('export.txt', 'w') as f:
  54. # f.write(script1)