user3424680
user3424680

Reputation: 1

Python program returning error I cannot seem to fix

I began this code by using a while loop to establish the menu (line 19-40) and it worked perfectly before adding the functions and import at the top. Now it keeps throwing back an indentation error at line 19 and none of my attempts other than removing all the functions seem to fix this problem. Any chance I overlooked something?

import string

def encrypt(input_val):
    en_key = input("Enter the number to shift by:")
    var = to_encrypt.upper()

    for char in var:
        shift = ord(char) + en_key
        encrypted += chr(shift)
        return encrypted.upper()

def decrypt(input_val):
    de_key = input("Enter the number to shift by:")
    var = to_decrypt.upper()

    for char in var:
        shift = ord(char) - de_key
        decrypted += chr(shift)
        return decrypted.upper()

def crack(input_val):


program_on = True
while program_on == True:
    print("Please select from the following options:\n \t1. Encrypt A Message\n \t2. Decrypt A Message\n \t3. Attempt To Crack A Message\n \t4. Quit")
    user_choice = input("Enter Your Choice: ")
    if user_choice == "1":     
        to_encrypt = input("Enter message to encrypt:")
        encrypt(to_encrypt)
        program_on = True
    elif user_choice == "2":
        to_decrypt = input("Enter encrypted message:")
        decrypt(to_decrypt)
        program_on = True
    elif user_choice == "3":
        to_crack = input("Enter encrypted message:")
        crack(to_crack)
        program_on = True
    elif user_choice == "4":
        print("Goodbye")
        program_on = False
    else:
        print("Give a valid response")
        program_on = True

Upvotes: 0

Views: 55

Answers (1)

Charles Clayton
Charles Clayton

Reputation: 17946

Seems to work now.

 def crack(input_val):
      pass

You can't define an empty function.

Upvotes: 1

Related Questions