I am porting caesar.c to python and am having a problem. The code below works for uppercase characters, for example 'A' outputs 'B' with a shift of 1. But lowercase characters, like 'a' with the same shift of 1 is outputting 'H' instead of 'b'. Fiddling around with my code before posting here I noticed if I remove the c.isupper condition, it prints the correct output for lowercase characters.
import sys
from cs50 import get_string
def main():
if len(sys.argv) is not 2:
print("Invalid arguments")
k = sys.argv[1]
plaintext = get_string("plaintext: ")
for c in plaintext:
if c.isupper:
c = ord(c) - ord("A")
c = c + int(k)
c = c % 26
c = chr(c + ord("A"))
elif c.islower:
c = ord(c) - ord("a")
c = c + int(k)
c = c % 26
c = chr(c + ord("a"))
print(c)
if __name__ == "__main__":
main()