79538503

Date: 2025-03-27 10:11:24
Score: 0.5
Natty:
Report link

I see the issue in your Caesar cipher code. You're overwriting the encoded variable in each iteration of the loop, so only the last character's result is saved. Also, the variable naming is causing confusion.

Here's a fixed version:

# alphabets
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"]

# inputs
plaintext = input("Enter the plain text you would like to encrypt: ")
key = int(input("Enter the key: "))

# actual cypher
result = ""
for char in plaintext.lower():
    if char in alphabet:
        # Find position and apply shift
        position = alphabet.index(char)
        # Use modulo to handle wrapping around the alphabet
        new_position = (position + key) % 26
        # Add the encrypted character to result
        result += alphabet[new_position]
    else:
        # Keep spaces and special characters as is
        result += char

print(result)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: helper