Skip to content
Merged
14 changes: 14 additions & 0 deletions ciphers/a1z26.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ def encode(plain: str) -> list[int]:
"""
>>> encode("myname")
[13, 25, 14, 1, 13, 5]
>>> encode("abCd")
Traceback (most recent call last):
...
ValueError: plain must contain only lowercase letters (a-z)
>>> encode("n0w")
Traceback (most recent call last):
...
ValueError: plain must contain only lowercase letters (a-z)
>>> encode("later!")
Traceback (most recent call last):
...
ValueError: plain must contain only lowercase letters (a-z)
"""
if not plain.islower() or not plain.isalpha():
raise ValueError("plain must contain only lowercase letters (a-z)")
return [ord(elem) - 96 for elem in plain]


Expand Down
2 changes: 1 addition & 1 deletion machine_learning/sequential_minimum_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def test_cancer_data():
print("Hello!\nStart test SVM using the SMO algorithm!")
# 0: download dataset and load into pandas' dataframe
if not os.path.exists(r"cancer_data.csv"):
request = urllib.request.Request( # noqa: S310
request = urllib.request.Request(
CANCER_DATASET_URL,
headers={"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"},
)
Expand Down