Please don't critique my algorithm as I'm a rank newbie (or go ahead, I can take it :) ). But I can't figure the following out.
shuffled_list always seems to be defined as () when I look in the debugger, so I continually get
File "C:\Python25\ca rds.py", line 29, in shuffle
while index:
AttributeError: 'tuple' object has no attribute 'append'
I have no idea whats wrong here.
Code:
def shuffle(): """ Return a list of indices from 0-51 with no repeats.""" index = range (0,52) shuffled_list = list() # or shuffled_list = [] does the same while index: card = random.choice(index) index.remove(card) shuffled_list.append(card) # print shuffled_list return shuffled_list
File "C:\Python25\ca rds.py", line 29, in shuffle
while index:
AttributeError: 'tuple' object has no attribute 'append'
I have no idea whats wrong here.
Comment