Python icon indicating copy to clipboard operation
Python copied to clipboard

Use list instead of string in rot13.py

Open ridds-io opened this issue 1 year ago • 1 comments

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.

ridds-io avatar Oct 28 '24 04:10 ridds-io

Hey Is this still open, Can I work on this?

mohit-bhandari45 avatar May 22 '25 04:05 mohit-bhandari45