Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Caesar Cipher Help
#1
Hello all,

I would like some expert python help. I'm very new to Python and I'm trying to create a simple caesar but it isn't working. It's stuck on the selection screen and it won't go any further.


def decrypt():
    a=raw_input("Give me the word to decrypt:")
    number=input("What was it shifted by?")
    b=list(a)
    str(b)
    c=[ord(x)for x in(b)]
    d=[]
    for i in c:
        d.append(i-number)
    e=[chr(i) for i in (d)]
    e="".join(e)
    print ("Decryption Successful, your word is ",e,"!")

def encrypt():
    a=raw_input("Give me a word:")
    number=input("Give me a number:")
    b=list(a)
    str(b)
    c=[ord(x)for x in(b)]
    d=[]
    for i in c:
        d.append(i+number)
    e=[chr(i) for i in (d)]
    e="".join(e)
    print ("Your Caesar shifted result (ascii code) is",e,"!")
    print ("Your key is ",number," remember that!")

def menu():    
    print ("\n\n\nWelcome to the Caesar Shifter.")
    print ("What would you like to do?")
    print ("Option 1:Encrypt Word")
    print ("Option 2:Decrypt Word")
    print ("If you would like to quit, press 0.")
    choice=input("Pick your selection: ")
    if choice==1:
        run=encrypt()
        run
        menu()
    elif choice==2:
        derun=decrypt()
        derun
        menu()
    elif choice==0:
        quit
    else:
        print ("That is not a correct selection, please pick either 1, or 2.")

menu()
Reply


Messages In This Thread
Simple Caesar Cipher Help - by as1221 - Jun-15-2017, 06:48 PM
RE: Simple Caesar Cipher Help - by sparkz_alot - Jun-15-2017, 07:46 PM
RE: Simple Caesar Cipher Help - by as1221 - Jun-15-2017, 08:16 PM
RE: Simple Caesar Cipher Help - by ichabod801 - Jun-15-2017, 09:43 PM
RE: Simple Caesar Cipher Help - by sparkz_alot - Jun-15-2017, 09:51 PM
RE: Simple Caesar Cipher Help - by sparkz_alot - Jun-15-2017, 09:54 PM
RE: Simple Caesar Cipher Help - by ichabod801 - Jun-15-2017, 10:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cesar Cipher ForsakenDusk 5 571 Apr-07-2024, 04:30 PM
Last Post: Pedroski55
Question Rsa Cipher Paragoon2 3 701 Nov-27-2023, 12:30 PM
Last Post: snippsat
  RSA Cipher with blocks Paragoon2 0 543 Nov-26-2023, 04:35 PM
Last Post: Paragoon2
  Caesar Cipher Help pbrowne 2 2,221 Jun-30-2021, 02:36 PM
Last Post: deanhystad
  Learning Python with a Caesar cipher Drone4four 5 4,958 Nov-21-2020, 07:21 PM
Last Post: bowlofred
  Coding caesar's cipher drewbty 3 2,847 May-16-2020, 10:05 AM
Last Post: DPaul
  Can someone please help me convert this simple C ROT cipher code to Python code? boohoo9 5 3,515 Jun-14-2019, 03:02 PM
Last Post: DeaD_EyE
  Caesar Cypher--- I don't understand why it doesn't work ironsheep 12 6,027 Nov-03-2018, 06:53 PM
Last Post: j.crater
  Newbie: Help with code related to Caesar Cipher jessiblah 2 3,442 May-15-2018, 04:28 PM
Last Post: nilamo
  Problem with caesar cipher lucaron 2 2,992 Feb-05-2018, 05:17 PM
Last Post: lucaron

Forum Jump:

User Panel Messages

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