0
I am working on a game type 21, and I am struggling to create a logic so that the values that the user receives through a draw with random.choice
are stored in a list and soon after I display the calculation of the elements until the user continues asking or until it does not exceed 21 and then will be displayed the message "you lost, scored 21 points".
I’m having difficulty creating this list that will receive and show the calculation and being that its elements will be the result of random.choice
that each user’s "yes" will result...
#21 the game
import random
baralho = [1,2,3,4,5,6,7,8,9,10,10,10]
def dar_cartas():
listaElementos = [[baralhos]]
print(random.choice([listaElementos]))
print(listaElementos)
print("\nBEM-VINDO(A) AO 21")
p1 = str(input("""\nDIGITE
\n[1] PARA JOGAR
\n[2] PARA SAIR
\n"""))
p2 = 0
if p1 == "1":
print("INICIANDO\n")
elif p1 == "2":
print("SAINDO\n")
while p1 != "2":
print("Sua carta é", random.choice(baralho))
while p2 != "não":
p2 = str(input("Você quer mais cartas?\n"))
print("Sua carta é", random.choice(baralho))
else:
break
else:
pass
#That’s what I’ve been able to do so far, it’s just sketches....
Thank you nandapand4 for real! You could explain the logic better to me privately?
– leosouza-3799
Sure! What is the best way to contact? @leosouza-3799
– nandapand4