Skip to main content
deleted 1 character in body
Source Link
toolic
  • 16.3k
  • 6
  • 29
  • 220

Overview

You've done ana good job:

  • You leveraged code written by others with the import
  • Used meaningful names for many of the variables

Here are some adjustments for you to consider, mainly for coding style.

Layout

I recommend moving the functions to the top, after the import. Having them in the middle of the code interrupts the natural flow of the code (from a human readability standpoint).

Unused code

I was about to recommend changing the name of the points function because it seemed too generic. However, I realized that it is not used, so it can be deleted.

Documentation

The card_points function always returns 11 for the Ace. The normal rules of Blackjack allow for the Ace to have a value of 1 in some circumstances.

You should add documentation to describe whether or not the Ace can have a value of 1.

Input

It is great that you cast the user input into lower-case. It would also be helpful to allow the user to be lazy and just input h for "hit" or s for "stand".

DRY

These lines appear 3 times in the code:

        print("Dealer's Cards:", dealer_cards)
        print("Dealer's Points:", dealer_points)
        print("Player's Cards:", player_cards)
        print("Player's Points:", player_points)

You could add them into a new function, named something like show_cards, then call the function 3 times.

Overview

You've done an good job:

  • You leveraged code written by others with the import
  • Used meaningful names for many of the variables

Here are some adjustments for you to consider, mainly for coding style.

Layout

I recommend moving the functions to the top, after the import. Having them in the middle of the code interrupts the natural flow of the code (from a human readability standpoint).

Unused code

I was about to recommend changing the name of the points function because it seemed too generic. However, I realized that it is not used, so it can be deleted.

Documentation

The card_points function always returns 11 for the Ace. The normal rules of Blackjack allow for the Ace to have a value of 1 in some circumstances.

You should add documentation to describe whether or not the Ace can have a value of 1.

Input

It is great that you cast the user input into lower-case. It would also be helpful to allow the user to be lazy and just input h for "hit" or s for "stand".

DRY

These lines appear 3 times in the code:

        print("Dealer's Cards:", dealer_cards)
        print("Dealer's Points:", dealer_points)
        print("Player's Cards:", player_cards)
        print("Player's Points:", player_points)

You could add them into a new function, named something like show_cards, then call the function 3 times.

Overview

You've done a good job:

  • You leveraged code written by others with the import
  • Used meaningful names for many of the variables

Here are some adjustments for you to consider, mainly for coding style.

Layout

I recommend moving the functions to the top, after the import. Having them in the middle of the code interrupts the natural flow of the code (from a human readability standpoint).

Unused code

I was about to recommend changing the name of the points function because it seemed too generic. However, I realized that it is not used, so it can be deleted.

Documentation

The card_points function always returns 11 for the Ace. The normal rules of Blackjack allow for the Ace to have a value of 1 in some circumstances.

You should add documentation to describe whether or not the Ace can have a value of 1.

Input

It is great that you cast the user input into lower-case. It would also be helpful to allow the user to be lazy and just input h for "hit" or s for "stand".

DRY

These lines appear 3 times in the code:

        print("Dealer's Cards:", dealer_cards)
        print("Dealer's Points:", dealer_points)
        print("Player's Cards:", player_cards)
        print("Player's Points:", player_points)

You could add them into a new function, named something like show_cards, then call the function 3 times.

Source Link
toolic
  • 16.3k
  • 6
  • 29
  • 220

Overview

You've done an good job:

  • You leveraged code written by others with the import
  • Used meaningful names for many of the variables

Here are some adjustments for you to consider, mainly for coding style.

Layout

I recommend moving the functions to the top, after the import. Having them in the middle of the code interrupts the natural flow of the code (from a human readability standpoint).

Unused code

I was about to recommend changing the name of the points function because it seemed too generic. However, I realized that it is not used, so it can be deleted.

Documentation

The card_points function always returns 11 for the Ace. The normal rules of Blackjack allow for the Ace to have a value of 1 in some circumstances.

You should add documentation to describe whether or not the Ace can have a value of 1.

Input

It is great that you cast the user input into lower-case. It would also be helpful to allow the user to be lazy and just input h for "hit" or s for "stand".

DRY

These lines appear 3 times in the code:

        print("Dealer's Cards:", dealer_cards)
        print("Dealer's Points:", dealer_points)
        print("Player's Cards:", player_cards)
        print("Player's Points:", player_points)

You could add them into a new function, named something like show_cards, then call the function 3 times.