4

I scored the web after an answer, found it, but still doesn't work. My caesar.py works fine, check50 shows me all happy faces except the last:

:( handles lack of argv[1] expected exit code 1, not 0

Here is my main() function, where I put the check right at the beginning:

def main():
    #check if argument was passed correctly
    if len(sys.argv) != 2:
        print("Usage: python caesar.py k")
        return 1

    k = int(sys.argv[1])

    while True:
         plainTxt = cs50.get_string("plaintext: ")
         if plainTxt:
             print("ciphertext: " , end = "")
             for c in plainTxt:
                 if c.isalpha():
                    c = cipher(c, k)
                 #print character
                 print(c, end="")
             #print new line
             print()
             #break the loop
             break

What am I missing??

Thanks a lot! Best, Daniel

1 Answer 1

7

main in Python no longer has a special meaning, but is a regular function, its name only chosen to conform to conventions based in C.

Try exit(1) instead of return 1.

Relevant python docs: https://docs.python.org/3/library/sys.html#sys.exit

You must log in to answer this question.

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