Please help me!



please help!! my class project was to build codes that could encrypt and decrypt caesar cipher codes. I took it upon myself to make both codes, and my decrypter code just destroys the shell. I turned to the internet and my teacher for help, but I have yet to come up with an answer. this code was written in the python IDLE shell, not any online python program. if you have an explanation or an answer, it would be very greatly appreciated. Here is the code. This is in the python version 3.6.4 in the IDLE shell. create a new file to run the program. be careful though! if you let it run for too long, it will crash the program and you won’t be able to close it.

alphabet = 'abcdefghijklmnopqrstuvwxyz'
Tris = 1
encrypted = 0
newMessage = ''
while Tris > 0:
    key = 1
    print("Please input anything you want to be decrypted.")
    message = input('word(s):')
    while key < 26:
        for charachter in message:
            if charachter in alphabet:
                position = alphabet.find(charachter)
                newPosition = (position + 1)%26
                newCharachter = alphabet[newPosition]
                newMessage += newCharachter
            elif charachter in ALPHABET:
                position = ALPHABET.find(charachter)
                newPosition = (position + 1)%26
                newCharachter = ALPHABET[newPosition]
                newMessage += newCharachter
                newMessage += charachter
        message = newMessage
        if message > newMessage:
        key += 1
    encrypted += 1
    print("would you like to decrypt another thing? 1 for yes 2 for no.")
    inpup = input()
    inpup = int(inpup)
    no = 2
    if inpup != no:
    if inpup == no:
        print("oh well, cya later!!")
print('you decrypted', encrypted,'messages.')

please contact me if you figure out why it dosent work.


If it crashes that means it stops, maybe you mean the exact opposite, that it keeps running forever? In that case reconsider the conditions for your loops (start by figuring out which one is causing you problems)

If you interrupt a python program it’ll tell you which line it was in when it was told to exit - that would tell you which loop it’s in. The keyboard shortcut for sending that is usually ctrl-c (if that’s not responding then perhaps you’re using all the memory. you should have some time to interrupt before that happens though, if that is the case)

Oh and take care that any code you share is an exact copy, you messed up the formatting so copying your code and trying to run it would only result in syntax error. Someone edited your post to fix the formatting.


for some reason when i tell it to turn the variable “message” into the variable “newMessage” it stacks “newMessage” on top of “message”.


If you’re saying = does concatenation, then, no, it doesn’t. Use prints to find out where you go wrong. Ask yourself what actions should be happening to obtain the desired result and then add prints which show that happening


Turns out that all i needed to do was move “newMessage = ‘’” into the while loop so it reset every time and didn’t stack. thanks for the help.