mardi 20 juin 2017

Random shuffle error message

Hi I am writing a Monopoly game simulator and have the following list of Community Chest Card Nos within a card object :-

self.CChcards_MessNo = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]

I want to shuffle these,with the following method

def shuffle(self):
   import random
   random.shuffle(self.CChcards_MessNo)

which works early on in the program but fails and gives the following message later in the main part of the program.

  File "C:\Users\David\AppData\Local\Programs\Python\Python35\lib\random.py", line 278, in shuffle
    for i in reversed(range(1, len(x))):
TypeError: object of type 'int' has no len()

This occurs when the program has cycled through the 16 cards and now needs to shuffle the cards




Aucun commentaire:

Enregistrer un commentaire