import random
import time
import math
import sys
card_numbers = [1,2,3,4,5,6,7,8,9]
card_suite = ["of hearts", "of diamonds", "of clubs", "of spades", "Queen", "King", "Jack", "Ace"] #4,5,6,7
random_number = random.choice(card_numbers)
random_number2 = random.choice(card_numbers)
random_number3 = random.choice(card_numbers)
random_suite = random.choice(card_suite)
numberadd = random_number + random_number2
numberadd2 = random_number + random_number2 + random_number3
def setup():
setupinput = raw_input("Type deal to deal the cards!")
if setupinput == "deal":
deal()
elif setupinput != "deal":
goodbye()
else:
print "Invalid Syntax!"
sys.exit(0)
def deal():
print "Your first card is... ", random_number, random_suite
print "Your second card is... ", random_number2, random_suite
if numberadd >= 21:
retry()
else:
thirdround()
def thirdround():
thirdroundinput = raw_input("Would you like another card?")
if thirdroundinput == "yes":
print "Your next card is... ", random_number3, random_suite
if numberadd2 >= 21:
retry()
else:
print "You win! Your total was... ", numberadd2
retry()
elif thirdroundinput == "no":
print "Okay... safe! Your total was... ", numberadd
else:
print "Invalid Syntax!"
sys.exit(0)
def goodbye():
print "Okay... goodbye!"
sys.exit(0)
def retry():
retryinput = raw_input("Would you like to try again?")
if retryinput == "yes":
setup()
elif retryinput != "yes":
goodbye()
else:
print "Invalid Syntax!"
sys.exit(0)
def ifblacklist():
if random_number or random_number2 or random_number3 == "Queen" or "King" or "Jack":
setup()
Brand new to coding, just finished coding this (almost done as a beginner project) and was wondering, if the random suite picks an ace, king, queen or jack, or do I make it so that it will output the number 10 (or 1 for the ace)?
Thanks
For clarification, the ifblacklist function is my attempt at making output the number 10, and was wondering if anyone could point me in the right direction of finishing it/rewriting
Aucun commentaire:
Enregistrer un commentaire