-4

I was trying to make a blackjack game,but here is two syntax error prevents to do that:

(errors at line 21,22,23,24 and all them all are syntax errors)

(deste=deck,desteo=players deck,desteb=computers deck,pas=pass)

import random
deste=[10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1]
desteo=[]
desteb=[]
pas=3
oyunbitti=0
desteo.append(random.choice(deste))
deste.remove(desteo[-1])
desteb.append(random.choice(deste))
deste.remove(desteb[-1])
def hamle():
    print("Destenin değeri : ",sum(desteo))
    print("Bilgisayar destesinin değeri : ",sum(desteb))
    print("Kalan pas hakkın: ",pas)
    yanit=input("Hamleni yap:\n1 Kart al\n2 Pas geç\n")
    if yanit==1:{
    desteo.append(random.choice(deste)
    deste.remove(desteo[-1]) 
        if sum(desteo)>21:{
            oyunbitti=1}}
print("test")

1 Answers1

1

Unless I've missed something, Python uses indentation for scope not curly braces ({}).

Fix that, and some wonky indentation and it prints "test" if thats what you're after

import random
deste=[10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1,
       10,10,10,10,9,8,7,6,5,4,3,2,1]
desteo=[]
desteb=[]
pas=3
oyunbitti=0
desteo.append(random.choice(deste))
deste.remove(desteo[-1])
desteb.append(random.choice(deste))
deste.remove(desteb[-1])
def hamle():
    print("Destenin değeri : ",sum(desteo))
    print("Bilgisayar destesinin değeri : ",sum(desteb))
    print("Kalan pas hakkın: ",pas)
    yanit=input("Hamleni yap:\n1 Kart al\n2 Pas geç\n")
    if yanit==1: # don't use curly braces
        desteo.append(random.choice(deste)) # these have been indented
        deste.remove(desteo[-1]) 
        if sum(desteo)>21: # no curly braces here either
            oyunbitti=1
print("test")
dwb
  • 2,136
  • 13
  • 27
  • thank to you i completed my game, i want to gift English version of game: https://drive.google.com/file/d/1rGTGlJts-s1F9q0ix3HUgW8RFiTX_AV1/view?usp=sharing – Ali Kerem Aug 29 '20 at 06:49