import random constant_array = "" red = blue = grey = black = 0 r1 = r2 = r3 = r4 = 1 blu1 = blu2 = blu3 = blu4 = 2 g1 = g2 = g3 = g4 = 3 bla1 = bla2 = bla3 = bla4 = 4 single_players = [r1,r2,r3,r4,blu1,blu2,blu3,blu4,bla1,bla2,bla3,bla4,g1,g2,g3,g4] _red = [1,1,1,1] #print random.randint(0,10 #red team x = 0 while x < 4: array = single_players[4:17] length = len(array) - 1 ray = random.randint(0,length) _red[x] = array[ray] del array[ray] print array x = x + 1 print _red
Ok I'm working on a game function where at the end of the game it remix's the teams. For some odd reason the del array[ray] isn't actually deleting the array item in the list I get the following output: C:\Documents and Settings\program\Desktop\python\pygame>remix.py [2, 2, 2, 4, 4, 4, 4, 3, 3, 3, 3] [2, 2, 2, 4, 4, 4, 4, 3, 3, 3, 3] [2, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3] [2, 2, 2, 2, 4, 4, 4, 3, 3, 3, 3] [2, 2, 4, 4] The _red function is fine, but the del function isn't working. What did I do wrong?
-- http://mail.python.org/mailman/listinfo/python-list