I have recently finished learning python from codecademy.com and have been using my newly found skills to try and convert a string into a distorted message only people with binary knowledge would understand.
import random
text = input("Phrase: ")
def t_rand():
test = int(random.randrange(0, 1))
if test == 1:
return True
elif test == 0:
return False
for x in text:
rand = t_rand()
if x == "l" or x == "L":
text.replace(x, bin(1))
elif x == "e" or x == "E":
text.replace(x, bin(3))
elif x == "i" or x == "I":
text.replace(x, bin(1))
elif x == "t" or x == "T":
text.replace(x, bin(7))
elif x == "o" or x == "O":
text.replace(x, bin(0))
else:
if rand:
text.replace(x, x.upper())
elif not rand:
text.replace(x, x.lower())
print(text)
PS: Sorry if it is a repost
Aucun commentaire:
Enregistrer un commentaire