[Tutor] FW: list of dict question

Francesco Loffredo fal at libero.it
Sat Oct 9 09:33:02 CEST 2010

On 08/10/2010 19.20, Roelof Wobben wrote:
> Oke,
> What I try to achieve is this :
> 1) Look if a team is known in stand.
> 2) If no, take care that the team is known in stand (this part I have written with your help)
> 3) if yes, make wedstrijden one more so wedstrijden is equal to number of played games of that team
>     and update the rest of the data
> With 3 I was thinking about this steps.
> 1) First search where the team is in stand.
You are very near to this: when you searched the team in stand, you 
could as well take note of what was your index in stand at the point 
where you found it. If you didn't find it, you have just added that team 
to stand, so its position must be stand[len(stand)-1]
(here a point about multi-user environments and the possibility of stand 
being modified on-the-fly should be added, but let's ignore it for now)
> 2) Update the data
Once you have a position, AND THE NUMBER OF PLAYED GAMES, this is trivial:

stand[position][wedstrijden] = numPlayedGames

You shoul NOT add one to wedstrijden, because every time that you run 
your program, for whatever reason, you are updating the record. And 
maybe you just wanted to test it! If you count the number of played 
games every time, you are sure that  the correct number is written on 
stand, even if you run the program thousands of times.
I imagine that you can count the played games searching in tournooi, but 
I'm not sure of it. You should keep that count somewhere.

> Roelof
-------------- next part --------------

Nessun virus nel messaggio in uscita.
Controllato da AVG - www.avg.com 
Versione: 9.0.862 / Database dei virus: 271.1.1/3184 -  Data di rilascio: 10/08/10 08:34:00

More information about the Tutor mailing list