samedi 16 mai 2020

how do you draw random numbers from a list and put them in another

I do not know how to draw 2 or more different numbers and put them in another list, so far I have tried this:

import random
def jugar(m):
  m = list(range(1, 14, 1)) * m
  random.shuffle(m)
  player1 = []
  for n in m:
    random.choice(m)
    player1.append(n)
    if n + n == 21:
      print("Nano jack")
    elif n + n < 21:
      random.choice(m)
      player1.append(n)
    elif n + n > 21:
      print("Loser")
    return player1
jugar(1)

but this returns me 2 equal numbers, it is similar to the game of blackjack, I want it to keep adding random numbers until it reaches 21 or more, thanks for the help in advance




Aucun commentaire:

Enregistrer un commentaire