I'm currently working in rewriting caesar into python, and I'm making good progress but I keep running into an error, after I enter the plaintext, it says
Traceback (most recent call last):
File "caesar.py", line 24, in <module>
main()
File "caesar.py", line 14, in main
if pt[i] + (k % 26) > 64 and pt[i] + (k % 26) < 91:
TypeError: not all arguments converted during string formatting
and I'm not sure how to fix the error. My code is: import cs50 import sys
def main():
k = sys.argv[1]
c = len(sys.argv)
if c == 2:
#print(k,c)
sys.stdout.write("Plaintext: ")
pt = cs50.get_string()
ptl = range(0, len(pt))
for i in ptl:
if pt[i] + (k % 26) > 64 and pt[i] + (k % 26) < 91:
sys.stdout.write(pt[i] + k % 26)
else:
return 1
if __name__ == "__main__":
main()