We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defcaesarCipher(s,k):# Write your code herenew_string=""forcharins:ifchar.isalpha():min_limit=ord("a")ifchar.islower()elseord("A")max_limit=ord("z")ifchar.islower()elseord("Z")pos=ord(char)+(k%26)ifmin_limit<=pos<=max_limit:new_string+=chr(pos)elifpos>max_limit:new_string+=chr((pos-max_limit)+(min_limit-1))else:new_string+=charreturnnew_string
Cookie support is required to access HackerRank
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 →