From 41ae948885ec49dc18841d62c1d605785bad8cae Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 7 Jul 2025 10:11:52 +0200 Subject: [PATCH] hill_cipher.py: Use `int()` to gracefully deal with float input * https://github.com/TheAlgorithms/Python/pull/12821#discussion_r2186998710 --- ciphers/hill_cipher.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ciphers/hill_cipher.py b/ciphers/hill_cipher.py index 19422688cd70..c690d29bd113 100644 --- a/ciphers/hill_cipher.py +++ b/ciphers/hill_cipher.py @@ -78,8 +78,10 @@ def replace_digits(self, num: int) -> str: 'T' >>> hill_cipher.replace_digits(26) '0' + >>> hill_cipher.replace_digits(26.1) + '0' """ - return self.key_string[(num)] + return self.key_string[int(num)] def check_determinant(self) -> None: """