Skip to content

Commit 5c05335

Browse files
authored
hill_cipher.py: Use int() to gracefully deal with float input (#12833)
* #12821 (comment)
1 parent cd3c3c3 commit 5c05335

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ciphers/hill_cipher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ def replace_digits(self, num: int) -> str:
7878
'T'
7979
>>> hill_cipher.replace_digits(26)
8080
'0'
81+
>>> hill_cipher.replace_digits(26.1)
82+
'0'
8183
"""
82-
return self.key_string[(num)]
84+
return self.key_string[int(num)]
8385

8486
def check_determinant(self) -> None:
8587
"""

0 commit comments

Comments
 (0)