For some dumb reason, I can't get my if..elif to print in python 3 but it somehow works in python 2. I'm not sure what I missed.
This is my if, elif
def encdec(userinput, machine, plaintext):
if userinput == 1:
print("-----------------------------------")
print("Encoded:")
enc = machine.encrypt(plaintext)
print(enc)
elif userinput == 2:
print("-----------------------------------")
print("Decoded:")
dec = machine.decrypt(plaintext)
print(dec)
This is my main using python 3's input function.
class main():
print("Cryptography")
print("[1] Encode")
print("[2] Decode")
userinput = input("Enter your choice: ")
plaintext = input("Plaintext: ")
rightkey = "SGLBIZHJMFTRXAVKNQPDWYCUOE"
leftkey = "XLEMFHIWOVNYRUDQCJPASGBTKZ"
if rightkey.isupper()==True:
rightkey = rightkey.lower()
if plaintext.isalnum()==True:
import re
plaintext = re.sub("[^a-zA-Z]+","",plaintext)
cm = SaveSpaces(UpperCase(CryptMachine(Chao(), leftkey)))
cm.set_alphabet(rightkey)
encdec(userinput, cm, plaintext)
if __name__ == "__main__":
main()
Aucun commentaire:
Enregistrer un commentaire