Hello! First time posting here so bare with me with my formating and other stuff.
I've got a task were I'm going to create a caesar cipher. You should be able to write a sentance to the program and the shifting it should use. Then the letters should be shifted with the number which was typed in. The program should not shift spaces and periods and when the ascii code for a letter exceeds 122 it should start from 97 and add then shift from there. Also when the ascii code exceeds 90 but not over 96 it should start from 65 and add the shift from there. In this program i'm not allowed to use "def" , "continue" or "return", so just very basic coding. Here's the code i've got:
str = input("Write a sentence: ")
b = input("Write the shift: ")
i = 0
for i in range(len(str)):
if ord(str[i]) == 46:
print(end=".")
elif ord(str[i]) == 32:
print(end=" ")
elif ord(str[i]) >= 90:
print(end=chr(ord(str[i] ) -26 + int(b)))
elif ord(str[i]) >= 123:
print(end=chr(ord(str[i] ) -26 + int(b)))
else:
print(chr(ord(str[i]) + int(b)), end="")
The problem is that it now has started to make lower case letter upper case which is not good. Otherwise it's not giving any errors atm.