You are viewing a single comment's thread. Return to all comments →
you are creating a new string every iteration.. i believe the following to be a more pythonic approach, with less time complexity
_,s,k = input(),input(), int(input()) def cipher(c): num = ord(c) if 97 <= num <= 122: return chr(((num-97+k)%26)+97) elif 65 <= num <= 90: return chr(((num-65+k)%26)+65) else: return c print(*[cipher(c) for c in s],sep='')
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
you are creating a new string every iteration.. i believe the following to be a more pythonic approach, with less time complexity