Feedback Wanted on My First Blackjack Game in Python!

0
19
Asked By CuriousCoder99 On

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).

2 Answers

Answered By HelpfulHarry42 On

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!

CodeCritique101 -

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.

Answered By QuestioningQuinn On

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!

CuriousCoder99 -

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.