I am a beginner programmer using Python 3.7 on Spyder, and when i run my code, it opens a system32 command prompt that immediately closes afterward. Nothing happens. The same thing happens when I try to press the debug button. I'll paste my code here. Edit: Thanks to oliverm, I have updated the code, but the code still will not start.
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
#imports
import random
#def the vars
credits = 10
playagain = None
jack = 10
queen = 10
king = 10
ace = 11 #Nice
x = 0
y = 0
a = 0
b = 5
playing = True
cardamount = 0
deck = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,jack,jack,jack,jack,queen,queen,queen,queen,king,king,king,king,ace,ace,ace,ace]
#def the functions
def greetings():
print("Greetings! Weclome to Blackjack! d\Do you wish to play?")
print ("Yes or No")
answer = input()
if answer == "Yes" or "yes" or "y" or "Y":
blackjack()
elif answer == "No" or "no" or "n" or "N":
print ("Alright then. Have a good day!")
else:
print("I have no idea what you just said. can you try that again?")
return
def bets():
print ("How much will you bet?")
print ("You have ",credits, " credits")
bet = int(input())
print ("Alright! Lets start!")
pass
def playerplay():
card1 = random.choice(deck)
card2 = random.choice(deck)
#ace logic here. an if statement.
cardlist = [card1, card2]
if card1 == ace and card2 == ace:
pastace = 2
card1 = 1
card2 =11
elif card1 == ace:
pastace = 1
if card2 + 11 > 21:
ace = 1
else:
ace = 11
elif card2 == ace:
pastace = 1
if card1 + 11 > 21:
ace = 1
else:
ace = 11
else:
pastace = 0
pass
cardamount = card1 + card2
print ("You drew a ", card1, " and a ", card2)
while playing == True:
print ("You currently have ", cardamount, " points with ", pastace, "aces" )
print ("Hit or Stand?")
hvalue = str(input())
if hvalue == 'Hit' or "hit" or "H" or "h":
cardlist.append(random.choice(deck))
#calculates cardamount
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
#paste ace logic here
if cardlist[x + 1] == ace:
pastace += 1
if cardamount > 21 and pastace == 1:
ace = 1
cardamount == card1 + card2
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
if cardamount > 21:
print("You have drawn over 21 cards. Now the dealer will play.")
playing = False
del cardlist[0:x]
pcardamount = cardamount
pastace = 0
x = 0
pass
else:
x += 1
return
elif cardamount > 21 and pastace > 1:
ace = 1
cardamount = card1 + card2
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
if cardamount > 21:
print("You have drawn over 21 cards. Now the dealer will play.")
playing = False
del cardlist[0:x]
pastace = 0
pcardamount = cardamount
x = 0
pass
elif cardamount - 22 > -11:
ace in cardlist = 11
return
else:
x += 1
return
else:
x += 1
return
elif hvalue == 'Stand' or 'stand' or 'S' or "s":
print ('Alright! Your total card amount is ', cardamount)
playing = False
del cardlist[0:x]
pastace = 0
pcardamount = cardamount
x = 0
pass
else:
print ("I'm sorry. What did you say?")
return
def outcome():
print("Your total card amount was", pcardamount, "and the dealer's was ", dcardamount)
if pcardamount > dcardamount and pcardamount <= 21 :
print("You win!")
credits += bet*2
elif pcardamount < dcardamount and dcardamount <=21 :
print("You lose...")
credits -= bet
else:
print("It's a tie!")
#says who wins here and defines playagain
playing = True
print("You now have ", credits, " credits.")
print ("Do you wish to play again?")
answer2 = str(input())
if answer2 == "Yes" or "yes" or "y" or "Y":
blackjack()
elif answer2 == "No" or "no" or "n" or "N":
print("Thank you for playing! Have a great day!")
else:
print: ("I have no idea what you just said. can you try that again?")
return
def hit():
cardlist.append(random.choice(deck))
#calculates cardamount
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
#paste ace logic here
if cardlist[x + 1] == ace:
pastace += 1
if cardamount > 21 and pastace == 1:
ace = 1
cardamount == card1 + card2
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
if cardamount > 21:
del cardlist[0:x]
pastace = 0
x = 0
dcardamount = cardamount
cardamount = 0
pass
else:
x += 1
return
elif cardamount > 21 and pastace > 1:
ace = 1
cardamount = card1 + card2
for y in len(cardlist):
cardamount += cardlist[y]
if y == len(cardlist):
y = 0
break
else:
y += 1
if cardamount > 21:
playing = False
del cardlist[0:x]
pastace = 0
x = 0
dcardamount = cardamount
cardamount = 0
pass
elif cardamount - 22 > -11:
ace in cardlist = 11
return
else:
x += 1
return
else:
x += 1
def dealerplay():
card1 = random.choice(deck)
card2 = random.choice(deck)
#ace logic here. an if statement.
cardlist = [card1, card2]
if card1 == ace and card2 == ace:
pastace = 2
card1 == 1
card2 ==11
elif card1 == ace:
pastace = 1
if card2 + 11 > 21:
ace = 1
else:
ace = 11
elif card2 == ace:
pastace = 1
if card1 + 11 > 21:
ace = 1
else:
ace = 11
else:
pastace = 0
pass
cardamount = card1 + card2
if cardamount < 17:
hit()
return
else:
del cardlist[0:x]
pastace = 0
x = 0
dcardamount = cardamount
cardamount = 0
pass
def blackjack():
bets()
playerplay()
dealerplay()
outcome()
#game functions put together
greetings()