12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import random
- occurences = ["What are the demands","There are no demands","The demands","Impossible demands", "Impossible demand","We demand the impossible","Impossible to demand"]
- democracy = "democracy"
- democracy_majuscule = democracy.upper()
- print(democracy_majuscule)
- liste = list( democracy )
- random.shuffle( liste )
- democracy_shuffled = ''.join( liste )
- print(democracy_shuffled)
- # read stopwords from file & save them in a list
- # read from file
- with open("occupy.txt", "r") as source:
- # for each line
- txt = source.readline()
- print(txt)
- new_txt = txt.replace(democracy, democracy_shuffled)
- print(new_txt)
- # clean returns
- #line = line.strip()
- #print(line)
- #split sentences into words
- #words = line.split()
- #for each words ...
- #for word in words:
- #print("words:", words)
- #print(" ".join(words))
- #replace what are the demands
- sentence = occurences[0]
- print("sentence:", sentence)
- sentence.replace("What are the demands"," what are the demands ")
- print(sentence)
- #replace there are no demands
- sentence = occurences[1]
- #sentence.replace("there are no demands","therearenodemands")
- #print(sentence)
- #reverse order
- sentence = occurences[4,5,7]
- #chaine = "impossible demands, impossible demand, impossible to demand"
- #chaine = chaine [::-1]
- #print(chaine)
- # passer en majuscule
- sentence = occurences[6]
- #sentence = sentence.upper()
- #print(sentence)
- # écrire la nouvelle liste comme chaîne de caractères dans un fichier texte
- #with open('export.txt', 'w') as f:
- #f.write(script1)
|