1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/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_en_grand = democracy.upper()
- print(democracy_en_grand)
- 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:
- txt = source.readline()
- print(txt)
- if democracy in txt:
- newtxt = txt.replace(democracy, democracy_shuffled)
- print(newtxt)
- # # for each line
- # for line in source:
- # # clean returns
- # line = line.strip()
- # #print(line)
- # #split sentences into words
- # words = line.split()
- # print(" ".join(words))
- # #for each words ...
- # for word in words:
- # if word == "democracy":
- # word = word.upper()
- # print(word)
- # liste = list( word )
- # random.shuffle( liste )
- # word = ''.join( liste )
- # print(word)
- # 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.replace("there are no demands","therearenodemands")
- # #print(sentence)
- # #reverse order
- # #chaine = "impossible demands, impossible demand, impossible to demand"
- # #chaine = chaine [::-1]
- # #print(chaine)
- # # majuscule
- # #if sentence == "We demand the impossible":
- # #sentence = sentence.upper()
- # # écrire la nouvelle liste comme chaîne de caractères dans un fichier texte
- # with open('export.txt', 'w') as f:
- # f.write(script1)
|