import math
import string
def rotationalCipher(input, rotation_factor):
alphabet_string = string.ascii_lowercase
lw = list(alphabet_string)
alphabet_string = string.ascii_uppercase
up = list(alphabet_string)
res = ''
for i in input:
if i.isalnum():
if i.isdigit():
res += str((int(i)%10+rotation_factor%10)%10)
elif i in lw:
res += lw[(lw.index(i)+rotation_factor)%26]
elif i in up:
res += up[(up.index(i)+rotation_factor)%26]
else:
res += i
return res
def printString(string):
print('["', string, '"]', sep='', end='')
test_case_number = 1
def check(expected, output):
global test_case_number
result = False
if expected == output:
result = True
rightTick = '\u2713'
wrongTick = '\u2717'
if result:
print(rightTick, 'Test #', test_case_number, sep='')
else:
print(wrongTick, 'Test #', test_case_number, ': Expected ', sep='', end='')
printString(expected)
print(' Your output: ', end='')
printString(output)
print()
test_case_number += 1
if name == "main":
input_1 = "All-convoYs-9-be:Alert1."
rotation_factor_1 = 4
expected_1 = "Epp-gsrzsCw-3-fi:Epivx5."
output_1 = rotationalCipher(input_1, rotation_factor_1)
check(expected_1, output_1)
input_2 = "abcdZXYzxy-999.@"
rotation_factor_2 = 200
expected_2 = "stuvRPQrpq-999.@"
output_2 = rotationalCipher(input_2, rotation_factor_2)
check(expected_2, output_2)