0

i m trying to use ord and chr, but there is no result at the prompt ? i guess it s something with chr because earlier i was having an error of that ciphertext wasnt an interger, suggesting me to use str that i tried but didnt work. what i am missing

~/workspace/pset6/ $ python caesar.py 3 plaintext: Hello ciphertext: Retry: here is section of my code where i use ord and chr:

import cs50 import sys

....

 #for each caracter in the text
            for c in range(len(plaintext)):
                if plaintext[c].isalpha():
                    conversion_key = int(ord('c') + k)
                    ciphertext = chr('conversion_key')
                    print("{}".format(ciphertext))
                else:
                    print(plaintext[c])#for each caracter in the text
            for c in range(len(plaintext)):
                if plaintext[c].isalpha():
                    conversion_key = int(ord('c') + k)
                    ciphertext = cs50.get_int()
                    ciphertext = chr('conversion_key')
                    print("{}".format(ciphertext))
                else:
                    print(plaintext[c])
0

The ciphertext is a string and not an int and instead of using cs50.get_string() we can only use str as string ciphertext = str(chr(conversion_key))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .