![]() |
A deciphering problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: A deciphering problem (/thread-34626.html) |
RE: A deciphering problem - Yoriz - Aug-23-2021 @DPaul You get an error with my code? What is the actual traceback error to see what line is throwing the error? What version of python are you using? I'm on 3.9.4 If you are not on version 3.9 Add the import from typing import Listand change list on line 38 @dataclass class CipherLine: line: str cipher_data_possibilites: list[CipherData]to List @dataclass class CipherLine: line: str cipher_data_possibilites: List[CipherData] RE: A deciphering problem - ibreeden - Aug-23-2021 (Aug-23-2021, 04:00 PM)DPaul Wrote: I would like to study Yoriz' solution too,Yes, I had the same error but I've got it working now. I had to upgrade from Python 3.8 to 3.9.5. Now it works. (The first time I just removed the type hints. ![]() Ivo. RE: A deciphering problem - DPaul - Aug-23-2021 @ Yoriz I'm also on 3.8.x. I'm a little confused as to the line numbers you propose to change.... This is the error message. Thanks for your help. Paul
RE: A deciphering problem - Yoriz - Aug-23-2021 @DPaul I edited my code in the previous posts so the code there will work with python version 3.8 or you can just remove the type hints like @ibreeden did, if you are not a fan of them. RE: A deciphering problem - DPaul - Aug-24-2021 OK, works perfectly. It allowed me to discover some python features I had not encountered before. In fact you generate the 66 possible shifts and then sum the blanks and the letters contained in 'aeiou', and you take the one with the best score. Nice. I did some "sensitivity analysis" and it would seem the presence of blanks is more crucial than the letters. (e,t,a) are the most used letters in English, the system even works with "e" alone. (But e.g. not with only 'y') Good show. RE: A deciphering problem - ibreeden - Aug-24-2021 Thank you @Yoriz , I learned a lot about type hints. They are very useful. |