# Nested Loop Mini Project — Caesar Cipher
# for + for + enumerate() + break — encrypt a real word

# ─────────────────────────────────────────────
# Caesar Cipher — word encryption
# ─────────────────────────────────────────────

alphabet = "abcdefghijklmnopqrstuvwxyz"
word = input("Enter a word: ").lower()
shift = int(input("Enter shift number: "))

encrypted = ""

for letter in word:
    for index, char in enumerate(alphabet):
        if char == letter:
            shifted_index = (index + shift) % 26
            encrypted += alphabet[shifted_index]
            break

print(f"Original:  {word}")
print(f"Encrypted: {encrypted}")

# ─────────────────────────────────────────────
# Test it
# ─────────────────────────────────────────────

# Enter a word: bull
# Enter shift number: 3
# Original:  bull
# Encrypted: exoo

# Enter a word: horn
# Enter shift number: 13
# Original:  horn
# Encrypted: ubea

# ─────────────────────────────────────────────
# What's really happening
# ─────────────────────────────────────────────

# outer loop — takes one letter from the word
# inner loop — walks through alphabet with enumerate()
# if match found — calculate shifted position — add to result — break
# break stops the inner loop — outer keeps going

# ─────────────────────────────────────────────
# Go further
# ─────────────────────────────────────────────

# Add decryption — shift in the opposite direction
# Handle spaces — skip with continue, add space to result
# Try shift 13 — encrypt "bull", then encrypt the result again
