52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
#!/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"]
|
|
|
|
# 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)
|
|
|
|
democracy = "democracy"
|
|
democracy_majuscule = democracy.upper()
|
|
print(democracy_majuscule)
|
|
|
|
liste = list( democracy )
|
|
random.shuffle( liste )
|
|
democracy_shuffled = ''.join( liste )
|
|
print(democracy_shuffled)
|
|
|
|
#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)
|