hill_cipher.py: Use int() to gracefully deal with float input (#12833)

* https://github.com/TheAlgorithms/Python/pull/12821#discussion_r2186998710
This commit is contained in:
Christian Clauss
2025-07-07 10:28:59 +02:00
committed by GitHub
parent cd3c3c3130
commit 5c05335b27

View File

@ -78,8 +78,10 @@ class HillCipher:
'T' 'T'
>>> hill_cipher.replace_digits(26) >>> hill_cipher.replace_digits(26)
'0' '0'
>>> hill_cipher.replace_digits(26.1)
'0'
""" """
return self.key_string[(num)] return self.key_string[int(num)]
def check_determinant(self) -> None: def check_determinant(self) -> None:
""" """