Finding attributes in a list
Ben
benji_tranter at hotmail.com
Tue Mar 29 08:05:24 EST 2005
Hi
In a list I have a number of soccer players. Each player has a
different rating for attacking, defending, midfield fitness and
goalkeeping.
I have devised a while loop that goes through this list to find the
best player at defending, attacking, midfield and goalkeeping. However
there is more than one defender per team so I therefore need it to find
the next best player.
Below is the code used to ascertain the best defender:
# STUFF TO FIND THE TOP DEFENDER
defender = 0 # The position of defender is set to the first player
in the knowledge base
topdefender = 0
c = 3 # the defensive rating of the first player in the list
d = (len(squadList)-4) # the defensive rating of the last player in the
list.
while c <= d:
if squadList[c] > topdefender:
topdefender = squadList[c]
defender = squadList[c-3] + " " + squadList[c-2] # The
defender variable is assigned to the forename and surname of the player
c = c + 8 # Move to the defensive rating of the next player in the
list
print defender
any help on this would be greatly appreciated.
thank you
More information about the Python-list
mailing list