diff --git a/examples/session03/cipher.py b/examples/session03/cipher.py new file mode 100644 index 0000000..4d1c15d --- /dev/null +++ b/examples/session03/cipher.py @@ -0,0 +1,28 @@ +import random + +alphabet = "abcdefghijklmnopqrstuvwxyz " + +alphabet_list = list(alphabet) + +# Create a new copy of alphabet list +cipher_list = list(alphabet_list) + +# This should be a list in order +print(cipher_list) + +message_text = "what has dates and sundays but cannot be eaten" + +random.shuffle(cipher_list) + +# This should be random now +print(cipher_list) + +cipher_text = "" + +for x in message_text: + index = alphabet_list.index(x) + cipher_char = cipher_list[index] + cipher_text += cipher_char + +# This is what +print(cipher_text) diff --git a/examples/session03/decipher.py b/examples/session03/decipher.py new file mode 100644 index 0000000..df6bd41 --- /dev/null +++ b/examples/session03/decipher.py @@ -0,0 +1,23 @@ +# This is the file for the deciphering partner. + +alphabet = "abcdefghijklmnopqrstuvwxyz " + +alphabet_list = list(alphabet) + +# Copy and paste the cipher list from your partner below, +# instead of the empty list. +cipher_list = ['v', 'w', 'u', 'q', 'k', 'm', 'g', 'z', 'l', 'n', 'e', ' ', 'd', 'b', 'x', 'y', 'i', 't', 'f', 'h', 'r', 'c', 'j', 'a', 'p', 's', 'o'] + + +# copy and paste the cipher_text from your partner in slack +# and assign it to the variable new_cipher_text +new_cipher_text = "jzvhozvfoqvhkfovbqofrbqvpfowrhouvbbxhowkokvhkb" + +decrypt_text = "" + +for y in new_cipher_text: + index = cipher_list.index(y) + decrypt_char = alphabet_list[index] + decrypt_text += decrypt_char + +print(decrypt_text) diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..5c1d742 --- /dev/null +++ b/test.txt @@ -0,0 +1,4 @@ +test +test2 +test3 +test4