python - Creating a function that assigns a random index location a specific number -


so i'm working on card game project in python, , i've been given starter code work with. have function called assigncard, supposed assign index location in array of 52 "cards" deck, player, or computer.

here code:

""" cardgame.py basic card game framework keeps track of card locations many hands needed """ numcards = 52 deck = 0 player = 1 comp = 2  cardloc = [0] * numcards suitname = ("hearts", "diamonds", "spades", "clubs") rankname = ("ace", "two", "three", "four", "five", "six", "seven",          "eight", "nine", "ten", "jack", "queen", "king") playername = ("deck", "player", "computer")  def main():     cleardeck()      in range(5):        assigncard(player)        assigncard(comp)      showdeck()     showhand(player)     showhand(comp)  def cleardeck():     cardloc[0] * numcards  def assigncard(playername):  def showdeck():     print("#        card                location")  def showhand(playername):  main() 

we aren't supposed edit above end of main function, thing writing functions inside main function.

we dealing 5 cards each player, question is, using for in range(5) deal 5 cards, how can exclusively deal 5 cards each player? i'm having bit of trouble associating arrays , indices, advice or tips appreciated!

generate array of numbers 0 51, map every number card. shuffle array. in every turn, give player first card in array , remove it.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -