Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use list instead of string in rot13.py #12306

Open
ridds-io opened this issue Oct 28, 2024 · 0 comments · May be fixed by #12319
Open

Use list instead of string in rot13.py #12306

ridds-io opened this issue Oct 28, 2024 · 0 comments · May be fixed by #12319
Labels
enhancement This PR modified some existing files

Comments

@ridds-io
Copy link

Feature description

SUGGESTED IMPROVEMENTS

Minor Efficiency Improvements:
The code is efficient for its purpose, but using a list to accumulate characters instead of concatenating strings directly within the loop improves performance slightly, especially for longer strings.

Redundant n Argument in dencrypt Function:
Since the ROT13 cipher is designed to shift characters by 13 positions, the n parameter is unnecessary for this particular implementation. Using a fixed 13-shift simplifies the code and makes it clear that it’s a ROT13 encryption.

Reversible Encryption Test Assumptions:
The doctest section’s example assumes that dencrypt will return the exact input message upon re-encryption with n=13. However, because n is modifiable, this behavior could break if n is set to a different value. Fixing n=13 would make the encryption/decryption consistent.

Testing for Errors and Assertions:
The function doesn’t include any assertions to validate inputs. Adding checks, especially for invalid inputs, would improve its robustness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment