Feedback Wanted on My First Blackjack Game in Python!

May 18, 2025 2 answers
Asked by YARD SALE
I've just started my journey in Python and decided to create a Blackjack game as my initial project. I'm looking for some constructive criticism on my code. Are there things I could've done better, or tips to make my coding process smoother? I feel like I could've reduced some lines of code if I had more Python knowledge, especially regarding card generation and tracking. Any advice would be greatly appreciated! You can check out my project on [GitHub](https://github.com/JTHCode/firstPythGame).

Answers

more tea please
I have a couple of questions! What happens if you draw two aces? And if someone bets a high amount, why does the game just stop? It might be better to implement an input loop until they enter a valid bet. Also, are you planning to add a split option? That would be fun!

YARD SALE: Great points! I had some trouble with the logic for the Aces, so I might have missed something there. Adding a split option is definitely on my to-do list, but I was short on time for this quick project.

Reply to this answer
SIDEWAYS_glance
Not a bad first project at all! Remember, the number of lines of code isnโ€™t everything; clarity is key. Here are a few thoughts: 1) Avoid using global variables unless absolutely necessary since they can lead to tricky bugs. 2) Try to stick to one naming conventionโ€”snake case is usually preferred in Python. 3) Your start game method seems a bit overloaded; consider breaking it into smaller parts. 4) Think about reusability. If you plan to create other card games, see if you can design your code to support that. 5) Definitely check out tools like SonarLint and PyLint to catch common mistakes. Good luck with your coding journey!

bell+rope: I also think infinite while loops can be risky. What if the condition never meets? Maybe set a maximum wait time or switch to a callback? Also, you can combine print statements to keep your code tidy.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions