Considering taking a hammer to the computer...
Dave Angel
d at davea.name
Tue Jan 1 17:34:26 EST 2013
On 01/01/2013 05:01 PM, Chris Angelico wrote:
> On Wed, Jan 2, 2013 at 7:14 AM, <worldsbiggestsabresfan at gmail.com> wrote:
>> floor_number = 0
>> for i in range(number_of_floors):
>> floor_number = floor_number + 1
> Matt's already given you the part you need (and it seems to have
> worked for you, yay!). Side point: Are you aware that i and
> floor_number are always going to have the same value? You can simplify
> this down to:
>
> for floor_number in range(number_of_floors):
>
> ChrisA
Actually, floor_number is one higher. The easiest way to fix that is to
adjust the range() parms.
for floor_number in range(1, 1+number_of_floors):
Naturally, in some hotels that might not have any rooms on one of the
floors. Divide by zero.
--
DaveA
More information about the Python-list
mailing list