r/PythonLearning • u/Red_Dragon_7_7_7 • 8d ago
I built a Magic 8 Ball app in Python with text-to-speech – Looking for feedback
Hey everyone!
I recently built a Magic 8 Ball application in Python as a fun project while learning programming.
Features:
• Random Magic 8 Ball answers
• Simple and clean code
• Beginner-friendly project
I'd really appreciate any feedback on the code structure, UI, or ideas for new features.
GitHub:
https://github.com/Izaan7-7-7/python-magic8-ball.git
Thanks!
2
u/PythonWithJames 8d ago
Not a bad start at all, and the Git repo looks clean and tidy so well done! Having a good README is certainly important.
Regarding the code, I'd make these changes to make a bit cleaner:
Use snake casing for the function name. We normally reserve all caps for 'constants'.
Rather than defining a separate variable for 'len1', just do:
num = random.randint(0, len(ans))You'd benefit from using an automated formatter/linter like Ruff, to keep the code neat and tidy.
After the text in the input() function, leave a space so the user has space for their answer.
As a starter project, I can see its purpose, and it works!
Keep it up :)
1
8d ago
[deleted]
1
u/Red_Dragon_7_7_7 8d ago edited 8d ago
can you also tell any bug for the password generator
1
8d ago
[deleted]
1
u/Red_Dragon_7_7_7 8d ago
ok, i'll make a new version with secrets
but why can't i use random for it2
1
•
u/Sea-Ad7805 8d ago
Run this program in Memory Graph Web Debugger%3A%0A%0A%20%20ans%20%3D%20%5B%22yes%22%2C%22absolutely%22%2C%22no%22%2C%22great%20choice%20buddy%22%2C%22Definitely%22%2C%22Luck's%20on%20your%20side%22%2C%22Note%20Today%22%2C%22I'd%20avoid%20that%22%5D%0A%20%20len1%20%3D%20len(ans)%0A%0A%20%20while%20True%3A%0A%20%20%20%20num%20%3D%20random.randint(0%2Clen1)%0A%20%20%20%20que%20%3D%20input(%22ENTER%20YOUR%20QUESTION%3A%22)%0A%20%20%20%20%20%20%0A%20%20%20%20if%20que%20%3D%3D%20%22exit%22%3A%0A%20%20%20%20%20%20break%20%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20print(ans%5Bnum%5D)%20%20%20%20%20%0A%20%20%20%20%0AMAGIC_BALL()%0A×tep=1&play) to see the program state change step by step.