I am getting wrong answer in second last assert.
to me it is problem in test condition !
Is there is something that is missing from question ?
def to_encrypt(text, delta):
cipher = ''
for char in text:
if char == ' ':
cipher = cipher + char
elif char != ' ':
cipher = cipher + chr((ord(char) + delta - 97) % 26 + 97)
else:
cipher = cipher + chr((ord(char) + delta - 122) % 26 + 122)
return cipher
if name == 'main':
print("Example:")
print(to_encrypt('abc', 10))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert to_encrypt("a b c", 3) == "d e f"
assert to_encrypt("a b c", -3) == "x y z"
assert to_encrypt("simple text", 16) == "iycfbu junj"
assert to_encrypt("---------rtant text", 10) == "swzybdkxd dohd" <<<<---------My output is " kkkkkkkkkbdkxd dohd "
assert to_encrypt("state secret", -13) == "fgngr frperg"
print("Coding complete? Click 'Check' to earn cool rewards!")
Created at: 2018/11/23 13:35; Updated at: 2018/11/23 15:26
The question is resolved.