Skip to content

Update passwordGenerator.py #2719

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

Merged
merged 1 commit into from
Jun 7, 2025
Merged

Conversation

ivanho-git
Copy link
Contributor

✅ Enhancements Made to Original Password Generator

🔧 1. Function Encapsulation
• Before: All code was in the global scope.
• After: Wrapped logic inside a generate_password() function to allow reuse and cleaner execution.

🌍 2. Random Country & Language
• Before: Only printed a list of countries; TODO was not implemented.
• After:
• Picks one random country using pycountry.countries.
• Picks one random language from pycountry.languages that has a valid name.

🎲 3. Used random.choice()
• Before: Used randint(0, len(tuple) - 1), which is error-prone.
• After: Replaced with random.choice() for better readability and safety.

🧹 4. Cleaned Up Code Structure
• Removed redundant comments.
• Added clear, consistent variable naming.
• Grouped constants together at the top.

🔠 5. Casing Logic Simplified
• Before: Conditional casing inside if blocks.
• After: Used more readable logic with descriptive variable (case_choice as "upper_colour" or "upper_animal").

🔐 6. Unified Password Construction
• Created a single formatted password string:
"{colour}{number}{animal}{special}"

🧾 7. Enhanced Output
• Print statements now show:
• The final password
• The country used
• The language used
• Clear labels for each

@geekcomputers geekcomputers merged commit 0147141 into geekcomputers:master Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants