Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8607073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:15:22+00:00 2026-06-12T03:15:22+00:00

def deck(): cards = range(1, 12) return choice(cards) def player(): card1 = deck() card2

  • 0
def deck():
    cards = range(1, 12)
    return choice(cards)

def player():
    card1 = deck()
    card2 = deck()
    hand = card1 + card2
    print card1, card2
    while hand < 21:
        choice = raw_input("Would you like to hit or stand?: ")
        print choice
        if choice == "hit":
            hand2 = hand + deck()
            print hand2     
        elif choice == "stand": 
                return hand 

Hello all,

I am trying to make a simple blackjack game in python. I have gotten this far and I seem to be stuck. When I try and play it asks me whether or I want to hit or stand which is good; however, my problem is that it seems to be generating new card values each time. That means if I was to hit and than stand it would return the original value rather than the new value of the three cards.

As you can tell I’m new to programming so any help is appreciated, I’d like to use as much as my own code as possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:15:23+00:00Added an answer on June 12, 2026 at 3:15 am

    If I understand your question correctly, then probably
    hand2 = hand + deck() inside your if is creating the problem.. You are assigning the sum to the new value, which is not even used anywhere..
    You need to update the same hand. So replace the above statement with: –

    hand = hand + deck()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
def ask(): global name, loca print What's your name? name = raw_input('> ') print
def myFunc( a, b ): def innerFunc( c ): print c innerFunc( 2 )
def test_method [a, b, c].map {|i| yield(i) } end If I call test_method like
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
def record return unless @supported klasses = profile_options[:formats].map { |f| RubyProf.const_get(#{f.to_s.camelize}Printer) }.compact klasses.each do
def display_home(request): from datetime import * now=datetime.today() print 'Month is %s'%now.month events=Event.objects.filter(e_date__year=datetime.today().year).filter(e_date__month=datetime.today().month,e_status=1).values('e_name','e_date') return render_to_response("SecureVirtualElection/home.html",{'events':
def myFunc( str ): print str=, str if str == None: print str is
def insertion_sort(A): for j in range(1, len(A)): key = A[j] i = j -
def func(a, b = 100): return a + b func(a) func(a,b = 100) Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.