Skip to content

Commit bb006ec

Browse files
author
Dadsaster
committed
made cryptogramy thingy
1 parent 471a533 commit bb006ec

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

cryptogram.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# create a random letter cypher for a string
2+
import random
3+
4+
def make_dash(string):
5+
out_string = ''
6+
for char in string:
7+
if char != ' ':
8+
out_string += '-'
9+
else:
10+
out_string += char
11+
return out_string
12+
13+
def make_new_key():
14+
new_alpha = []
15+
alphabet = list('abcdefghijklmnopqrstuvwxyz')
16+
alpha_save = alphabet[:]
17+
while alphabet:
18+
pick = random.choice(alphabet)
19+
new_alpha.append(pick)
20+
index = alphabet.index(pick)
21+
alphabet.pop(index)
22+
return dict(zip(alpha_save, new_alpha))
23+
24+
def scramble(string, mapper):
25+
out_string = ''
26+
for char in string:
27+
if char != ' ':
28+
out_string += mapper[char]
29+
else:
30+
out_string += char
31+
return out_string
32+
33+
sentence = "the quick brown fox jumps over the lazy dog"
34+
new_key = make_new_key()
35+
print(make_dash(sentence))
36+
print(scramble(sentence, new_key))

hello.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""A tiny Python program to check that Python is working.
32
Try running this program from the command line like this:
43
python hello.py

0 commit comments

Comments
 (0)