Question: How do i import random?
Repl link/Link to where the bug appears: https://replit.com/@idontlikeconfli/BlueUnderstatedDividend
Screenshots, links, or other helpful context:
code snippet
Question: How do i import random?
Repl link/Link to where the bug appears: https://replit.com/@idontlikeconfli/BlueUnderstatedDividend
Screenshots, links, or other helpful context:
code snippet
you seem to have already imported random? what exactly do you need help with?
thank you for your reply, I appreciate it. When i press run I want to get random card dealt
https://replit.com/@idontlikeconfli/BlueUnderstatedDividend
this is pretty easy to do, just use random.randint(), with the first parameter being the lowest value you’d like to be able to pick (in your situation, 1), and the second parameter being the highest value you’d like to be able to pick. then you can just search it up in the array and print it out into the console
To get and remove a card from a list cards
, you can pop a random index with random.randrange
. Make sure to check that cards
is not empty. (alternatives include random.choice
and random.sample
)
card = cards.pop(random.randrange(len(cards)))
If you do not need to remove the card from the list, use random.choice
.
card = random.choice(cards)