Strings are immutable in Python, so you can't remove and insert characters.
Instead, do it like this:
result = ''
offset = 3
for i in range(0,len(x)):
val = ord(x[i]) + offset
if val > ord('z'):
val = val - 26
result = result + chr(val)
print(result)
Using a variable to hold your offset means that your Caesar Cypher becomes more flexible, comparing to the last valid value means the wrap works regardless of the value of
offset
, provided it is positive.