Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35937

Re: Considering taking a hammer to the computer...

Date 2013-01-01 17:34 -0500
From Dave Angel <d@davea.name>
Subject Re: Considering taking a hammer to the computer...
References <2f5053ab-a646-49d3-a569-61468f518b9f@googlegroups.com> <39abb4d2-277a-4ac9-8574-0d3e3751b7ef@googlegroups.com> <CAPTjJmqqGB1RiRipFY6eJmKvzeAaONWfsA0qB0bYMasR=sUtxA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1541.1357085113.29569.python-list@python.org> (permalink)

Show all headers | View raw


On 01/01/2013 05:01 PM, Chris Angelico wrote:
> On Wed, Jan 2, 2013 at 7:14 AM,  <worldsbiggestsabresfan@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2012-12-31 15:42 -0800
  Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-01 11:08 +1100
  Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-01 11:09 +1100
  Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 19:29 -0500
  Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 19:34 -0500
  Re: Considering taking a hammer to the computer... Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-01-01 01:36 +0100
  Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2012-12-31 17:30 -0800
    Re: Considering taking a hammer to the computer... Mitya Sirenef <msirenef@lightbird.net> - 2012-12-31 21:00 -0500
    Re: Considering taking a hammer to the computer... Tim Chase <python.list@tim.thechases.com> - 2012-12-31 22:41 -0600
    Re: Considering taking a hammer to the computer... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-01 14:35 -0500
  Re: Considering taking a hammer to the computer... Modulok <modulok@gmail.com> - 2012-12-31 20:59 -0700
  Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 12:14 -0800
    Re: Considering taking a hammer to the computer... Matt Jones <matt.walker.jones@gmail.com> - 2013-01-01 14:46 -0600
      Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 13:57 -0800
      Re: Considering taking a hammer to the computer... worldsbiggestsabresfan@gmail.com - 2013-01-01 13:57 -0800
    Re: Considering taking a hammer to the computer... Chris Angelico <rosuav@gmail.com> - 2013-01-02 09:01 +1100
    Re: Considering taking a hammer to the computer... Dave Angel <d@davea.name> - 2013-01-01 15:28 -0500
    Re: Considering taking a hammer to the computer... Dave Angel <d@davea.name> - 2013-01-01 17:34 -0500
  Re: Considering taking a hammer to the computer... MRAB <python@mrabarnett.plus.com> - 2013-01-01 00:02 +0000

csiph-web