Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ciphers/a1z26.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ def encode(plain: str) -> list[int]:
"""
>>> encode("myname")
[13, 25, 14, 1, 13, 5]
>>> encode("")
Traceback (most recent call last):
...
ValueError: input cannot be empty
>>> encode("Hello")
Traceback (most recent call last):
...
ValueError: input must contain only lowercase letters a-z
"""
if not plain:
raise ValueError("input cannot be empty")
if not plain.islower() or not plain.isalpha():
raise ValueError("input must contain only lowercase letters a-z")
return [ord(elem) - 96 for elem in plain]


Expand Down