Python Forum
Caesar Cypher--- I don't understand why it doesn't work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Caesar Cypher--- I don't understand why it doesn't work
#5
alphabet= "abcdefghijklmnopqrstuvwxyz"
cleartext= input()
cleartext=cleartext_lowercase()
def encrypt(cleartext):
    codedtext = " "
    for character in cleartext:
            if character in alphabet:
                newcharacter= (alphabet.find(character) + 13) %26
                codedtext += alphabet[newcharacter]
            elif:
                codedtext += character
            return codedtext
print(encrypt(cleartext))
This is my python code for a caesar cipher I made after watching the Youtube Channel KidsCanCode Lesson 1.10. I already asked Chris Bradfield for help and thanks to his input, I fixed the errors he told me, but I still have errors. I don't want to bug him by asking him again to look at why this code doesn't work. My goal is to type in sheep and have the secret message as furrc. I recommend that you watch Chris Bradfield's video for clarification.

Just run the program by typing in the word sheep-- and you will get syntax error( even though elif: is cif correct), why does python not accept elif. My goal is to cesear cipher the word sheep.

How are you writing with/in a green bar??

Also, why does it say Unladen Swallow under my username???
Reply


Messages In This Thread
RE: Caesar Cypher--- I don't understand why it doesn't work - by ironsheep - Nov-01-2018, 01:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP doesn't work YKR 1 619 Mar-28-2025, 02:10 PM
Last Post: snippsat
  beginner doesn't understand import cimerio 3 488 Feb-12-2025, 05:02 PM
Last Post: cimerio
  I'm trying to install python 3.11.11 on windows 10 - it doesn't work Petonique 2 1,699 Feb-04-2025, 05:42 PM
Last Post: snippsat
  Extending list doesn't work as expected mmhmjanssen 2 1,353 May-09-2024, 05:39 PM
Last Post: Pedroski55
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 1,883 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 3,438 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 1,798 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 2,560 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 6,664 May-30-2022, 03:31 PM
Last Post: bowlofred
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,978 Dec-18-2021, 02:38 AM
Last Post: knight2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020