mardi 21 novembre 2017

Assigning points based on length of list of list

I was trying to figure out how to assign numbers to a certain point in a list based on how many items that there were left in a list.
For example:

def prizeHandout(prizeWinners):
    for x in range(len(prizeWinners)):
        if len(prizeWinners) == 24:
            prizeWinners[x][2] = (int(prize[0]))
        elif len(prizeWinners) == 12:
            prizeWinners[x][2] = (int(prize[1]))
        elif len(prizeWinners) == 6:
            prizeWinners[x][2] = (int(prize[2]))
    print(prizeWinners)  

I have a global variable 'prize' which is a list with the prizes [10, 20, 30,....]
The 'prizeWinners' are in a list of list in this format [[ab, 2, 0], [ba, 5, 0], [aa, 12, 0], .....]
In the 'prizeWinners' variable, the assignment of the 'prize' should add on to the current space [2] and be added to the previous number if there was one.
Can't seem to get this working.
Any help would be appreciated, thanks :)

Aucun commentaire:

Enregistrer un commentaire