It is close to two months to progress to day eight in my coding journey. A Progress Entry.

The head is filled with nothing but random thoughts of how to tweak this code of mine.

image.png

import art

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print(art.logo)
go=True

while go:
    direction = input("Type 'encode' to encrypt, type 'decode' to decrypt:\n")
    text = input("Type your message:\n").lower()
    shift = int(input("Type the shift number:\n"))
    if shift >= 26:
        shift = (shift%26) 
       
    def caesar (cipher_text, shift_amount, caesar_directive):
        letter_dump = alphabet[0:shift_amount]
        cut_alpha = alphabet[shift:]
        cut_alpha.extend(letter_dump)
        result = ""
    
        for letter in (cipher_text):
            if caesar_directive == "encode":
                position = alphabet.index(letter)
                result += cut_alpha[position]
            elif caesar_directive == "decode":
                position = cut_alpha.index(letter)
                result += alphabet[position]
        print(f"The {caesar_directive}d text is {result}")
    
    caesar(cipher_text=text,shift_amount=shift,caesar_directive=direction)

    reload = input("Do you want to use Casear Cipher again? type yes or no.\n").lower()

    if reload == "no":
        go=False

Now this is day eight of my one hundred day coding course. I think it has taken me close to two months to progress to this point. I foresee myself completing this course in a year or more.

I do see some improvement but I am still using lots of googling and using stack overflow to find ideas on how to solve each and every challenge this course is throwing my way.

@wittyzell I have abandoned trying to solve your challenge you gave me. I may or may not go back to it in the distant future. I can't say not too distant since I am struggling with time management. Too many pursuits.

Out of interest and context of my progress.

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

def caesar(start_text, shift_amount, cipher_direction):
  end_text = ""
  if cipher_direction == "decode":
    shift_amount *= -1
  for char in start_text:
    #TODO-3: What happens if the user enters a number/symbol/space?
    #Can you fix the code to keep the number/symbol/space when the text is encoded/decoded?
    #e.g. start_text = "meet me at 3"
    #end_text = "•••• •• •• 3"
    position = alphabet.index(char)
    new_position = position + shift_amount
    end_text += alphabet[new_position]
    
  print(f"Here's the {cipher_direction}d result: {end_text}")

This is the teachers code for the same work and while it is tempting to just do the exercises using her format I am sticking to just continuing with the code I started with, which is the code block above hers.

I am close to finishing day eight. I have just one more challenge of improving the UI for the cipher challenge. All up it consists of four tasks. This one being the fourth iteration on the previous three done.

Create encryption function.
Create decryption function.
Combine both functions.

This last one entails adding a logo, ensuring the code will allow for any amounts greater than the alphabet numbers (26), loop code until user wants out and ensure code can handle actual sentence used for encrypting and decrypting.

Will take a break from here though because my head is swimming like my starting statement.

I really do believe when it comes to my learning, not learning as a general sense I have to take my time and just let new knowledge become digested and adapted into my over all neural network.

break page.png

Thanks for your time

If you enjoy my posts, and would like to support me with more than an upvote, thank you very much, see my links below.


Browse merch here.


Click Image

Geomining to a better future referral link if you decide to support me

Click Image

bitcoin public wallet.png

Click Image

Shameless referral link to space game



0
0
0.000
6 comments
avatar

Oh no worries, those are just suggestions. I hope you keep your code in a repo so when your PC crashes, your code is still alive somewhere. 😅

0
0
0.000
avatar

Yeah, they are all kept on repl.
Just the free account cos I don't really want to pay for anything LOL

Free is always better, maybe if one day I get to bigger codes I will start to do proper repo. But I am noob so ...

0
0
0.000
avatar

Haven't heard of repl, it's my first time today.
I've always used github 😅

0
0
0.000
avatar

I have seen github, but that platform is intimidating for a noob

0
0
0.000