Considering taking a hammer to the computer...

Dave Angel d at davea.name
Tue Jan 1 21:28:27 CET 2013


On 01/01/2013 03:14 PM, worldsbiggestsabresfan at gmail.com wrote:
> OK, thank you all for your help yesterday!
>
> Here's where we are today (using python 3.3.0)
>
> He has everything running well except for the final calculations - he needs to be able to total the number of rooms in the hotel, as well as the number of occupied rooms.  We have tried several different things and can't come up with a successful command.  Any help you can give will be much appreciated!!
There are two ways to get those totals, depending on whether you know
how to work lists or not.  If you do, then you should make a list of
occupied_rooms, and sum() it at the end, and make a list of
rooms_on_flow, and sum that at the end.

But as you discovered, sum() won't work on an int (BTW, you should give
the entire traceback instead of saying "doesn't work".  In this case, it
was obvious, but it might not be.)

On the other hand, if you don't know what a list is, then you need to
accumulate those numbers as you go.  Either way, you need extra
variables to represent the whole hotel, and you need to do something
inside the loop to adjust those variables.



-- 

DaveA




More information about the Python-list mailing list