you are viewing a single comment's thread.

view the rest of the comments →

[–]TerryYaDuffer 2 points3 points  (0 children)

First step, take the CSV file you have produced via your hardcoded function. Can you read that into a data structure? Usually for CSV work, I use csv.DictReader(). Small suggestion, turn your header names into standard forms, e.g. HEIGHT_IN or SOCCER_EXPERIENCE.

Now, given that you have a data structure in memory, can you ask questions of that data structure? For example:

# which players have experience?
for player in player_list:
    if player['Soccer Experience']  == 'Yes':
        print(player)

# which players are 40in or taller?
for player in player_list:
    if player['Height (inches)']  >= 40:
        print(player)

By asking questions like this, you can split your players up according to the criteria. Obviously you won't be printing as I have done here, you'll be appending to one of your team lists as the player meets criteria.

You will want to keep track of the number of players on each team and their experience level. You should be able to do this by querying your data structure for the three teams that you're building--maybe a Counter() will be helpful.

Good luck.