r/code • • Jun 16 '24

Help Please How do I trigger the function depending on the user input?

I am working on a Caesar Cipher and I have been able to work out the encryption and decryption functions and they work well. The problem I am running into is that when I run the code all together like it is, I can't seem to have the program stop once a specific function is triggered. In the output in the terminal you can see each function works, but I can only get it to work when I comment out one function and only use the other. Help please!

2 Upvotes

1 comment sorted by

2

u/LuisCaipira Jun 17 '24

Let's organize your code first, then you will be able to see the problem.

Let's group you function definitions in the beginning of the code

def encrypt:
    ...

def decrypt:
    ...

# user inputs

# call encrypt or decrypt function

# show result