primeiro commit com exercicios de Exercism realizados até esta data
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
def rotate(text, key):
|
||||
cyphertext: str = ""
|
||||
for letter in text:
|
||||
if letter.isalpha():
|
||||
# check if letter is uppercase or lower case,
|
||||
# and set add_value accordingly
|
||||
if ord(letter) >= ord("A") and ord(letter) <= ord("Z"):
|
||||
add_value = ord("A")
|
||||
else:
|
||||
add_value = ord("a")
|
||||
# mod_value
|
||||
mod_value = add_value + 26
|
||||
cyphertext += chr(
|
||||
((ord(letter) + key) % mod_value)
|
||||
+ (((ord(letter) + key) // mod_value) * add_value)
|
||||
)
|
||||
else:
|
||||
cyphertext += letter
|
||||
return cyphertext
|
||||
Reference in New Issue
Block a user