0

I imported the below mention libraries but still getting this tracback error anyone who can help
import cs50
import sys
def main():

if len(sys.argv) is not 2:

    print("Please give me valid key")

    exit(1)

key = int (sys.argv[1])

m = key %26

if m == 0:
    print("invalid key")

code = cs50.get_string()

if code is not None:
    for i in range ( len(code)):
        c = 0

        if cs50.isupper(code[i]):
            c = ((ord (code[i]) - 65 + m) % 26 )+ 65
            print(chr(c))

        elif cs50.islower(code[i]):
            c = ((ord(code[i]) - 97 + m) % 26) + 97

        else:
            print(code[i])

print()

if name == "main": main()

[1]: https://i.stack.imgur.com/yqnKq.png

0

The issue here is that the method isupper() does not exist in the cs50 library. Instead, it's built in to Python by default. Read this section of the Python documentation to learn more about built-in string methods.

In your case you would call code[i].isupper(). This is one example of the important differences to note as you begin working in Python after C.

You must log in to answer this question.

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