[Solved] How to call a function in an if statement? [closed]


so I also have the solution organized:

Try replacing line 74 with: choice1 = ""

If you noticed, you are asking for another input before the while loop. and then you go into the loop. Try deleting row 74 and assign a different value for choice. because even if you enter the correct word, it will misunderstand it in the while loop because it is on the list. If you delete line 74, it will not be enough, because choice1.lower () not in allowed_choices: will show the error choice was not found.

def main2():
    print("Vul hieronder de tekst die je wilt ontsleutelen.")
    dec_word = input("> ")
    print("Vul hieronder de cijfer van de verschuiving. (Van 1 tot 25!)")
    dec_keys = int(input("> "))
    allowed_numbers = list(range(1, 26))
    while dec_keys not in allowed_numbers:
        print("Foute Optie!")
        dec_keys = int(input("> "))

    dec_decrypted = decrypt(dec_keys,dec_word)
    print("Ontsleuteld:"+ dec_decrypted +".")
    print("Ontsleuteling van:"+ dec_word +".")
    print("Verschuiving: "+ str(dec_keys) +".")
    input("prompt:")

def main():
    print("Vul hieronder de tekst die je wilt versleutelen.")
    word = input("> ")
    print("Vul hieronder de cijfer van de verschuiving. (Van 1 tot 25!)")
    allowed_numbers = list(range(1, 26))
    keys = int(input("> "))
    while keys not in allowed_numbers:
        print("Foute Optie!")
        keys = int(input("> "))

    encrypted = encrypt(keys,word)
    print("Versleuteling: "+ encrypted +".")
    decrypted = decrypt(keys,encrypted)
    print("Versleuteld van: "+ decrypted +".")
    print("Verschuiving: "+ str(keys) +".")
    input("prompt:")


print("Wil je een woord ontsleutelen of versleutelen")
choice1 = ""
allowed_choices = ["ontsleutelen", "versleutelen"]
while choice1.lower() not in allowed_choices:
    choice1 = input("> ")
    if choice1.lower() == ("versleutelen"):
        main()
    if choice1.lower() == ("ontsleutelen"):
        main2()

8

solved How to call a function in an if statement? [closed]