0
if (len(sys.argv) != 2):
    print("please enter a key")

"""understand the key"""
k = sys.argv[1]

"""prompt for input text"""
message = cs50.get_string("plaintext:")

"""get ready to produce processed result"""
print("ciphertext")


for i in message:
    """preserves uppercase"""
    if (i.isalpha()) == True:
        if (i.isupper()) == True:
            """the real conversion via the unicode"""
            z = (ord(i) -65) + k
            y = (z % 26) + 65
            print(chr(y), end="")
        """deals with the lowercase letters"""
        else:
            w = (ord(i) - 97) + k
            v = (w % 26) + 97
            print(chr(v), end="")
    """for the blank space"""
    else:
    print(chr(i))
1

Very often, a syntax error on an apparently correct line indicates the preceding line. It is complaining about the indent of the comment on the line before.

3
  • i had to delete the comment to get rid of it, only when another problem came my way Aug 5 '18 at 9:41
  • Indenting the comment (to match the line above it) should have/would have fixed that particular error. Assume you mean the error moved to this line k = sys.argv[1]. That is a run-time error which you will get if you execute the program with no arguments. Aug 5 '18 at 21:06
  • That sorts everything, thanks Aug 6 '18 at 14:42

You must log in to answer this question.

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