<jupyter_start><jupyter_text>Encoding a text Let's start our first small project. Imagine, that you want to send a secret message. Therefore, you want to use a very simple encoding method called [Ceasar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher). Let's decide which characters we are allowed to use and which message we want to send.<jupyter_code>alphabet = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .")   # all characters we want to use
text_clear = "Mission accomplished. Meeting point is Mailand. I will wear a black coat." # message we want to send<jupyter_output><empty_output><jupyter_text>Now, to get a encoded alphabet we need to shift our list by a certain amount of characters. Therefore we can use a combination of __pop()__ and __append()__.Run the cell below and try to understand what is happening. By now the list is shifted by 3 characters. To increase the security level, modify the cell, that it shifts the list by the length of the text you want to encode.<jupyter_code>alphabet_encoded = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .")
for i in range(3):
    alphabet_encoded.append(alphabet_encoded.pop(0))

print(alphabet_encoded)<jupyter_output><empty_output><jupyter_text>In the next step, we need to map the alphabet to its encoded version, by using a dictionary.<jupyter_code>encoder = dict(zip(alphabet, alphabet_encoded))
encoder<jupyter_output><empty_output><jupyter_text>Finally, we write our secrete message. Starting with an empty string, we go through our message and add an encoded letter to it.<jupyter_code>text_encoded = ""
for letter in text_clear:
    text_encoded += encoder[letter]
print(text_clear)
print(text_encoded)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06986143187066975, 'fraction_numerical': 0.0017321016166281756, 'mean_word_length': 6.073469387755102, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '627928', 'license': 'Apache-2.0', 'n_tokens_mistral': 529, 'n_tokens_neox': 509, 'n_words': 198, 'path': 'assignment_01.ipynb', 'repo_name': 'KonstanzPythonSchool/assignment_01', 'size': '1732'}