Let's do this: if you have another question, comment every line of this snippet with what you think is doing first.
#!/usr/bin/python
# This is an example intended as a guide only and not as a complete solution
teams = {}
with open("test") as f:
for line in f:
lname, fname, team = line.rstrip('\n').split(',')[:3]
if team in teams:
teams[team].append(" ".join([fname, lname]))
else:
teams[team] = [" ".join([fname, lname])]
team_names = "\n".join(sorted(teams))
while True:
print "=" * len("team names")
print "Team Names"
print "=" * len("team names")
print team_names
selection = raw_input("Select a team from above list or press q: ")
if selection == 'q':
break
if selection in teams:
print "Team " + selection + " has the following players:"
print ", ".join(teams[selection])
else:
print "Team " + selection + " not found"
Sorry, to bring this up again, but I just thought of something that I can add to this for practice. After the user selects the team and the players show up, how would I allow the user to select one of those players to report their statistics. I was thinking about storing each part of the line as a separate statistic, but was not sure how go from the first selection menu to the next.