newbie question!

Terry Reedy tjreedy at udel.edu
Wed Oct 15 16:49:24 EDT 2003


"Brian" <quigleyb at iol.ie> wrote in message
news:bmk0dc$4r1$1 at kermit.esat.net...
> Hi, im new to python and have a simple question...
>
> i want too have a list of values - say numbers of tables in a
restaurant...
> 1,2,3,4,5. i want to associate a value with each of these numbers...
eg. yes
> or no. when a person books table 2, the value corresponding to 2
turns to no
> [not available] etc...
>
> what would be the best way to do this ? a little code help would
help aswell
> !!! - newbie

Give n tables beginning with table 1, one could use a list initialized
as
tables = (n+1)*[True]
Then 'tables[2] = False' when booked.
But I would start with 'tables = (n+1)*[False]' so I could write
tables[2] = <booking information>
when booked rather than merely True for booked.

You can either ignore tables[0] or use it to keep a count of free
tables, in which case initialize tables[0]=n and subtract 1 for each
booking.

Terry J. Reedy






More information about the Python-list mailing list