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


Groups > comp.lang.python > #110688

Re: Iteration, while loop, and for loop

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: Iteration, while loop, and for loop
Date Tue, 28 Jun 2016 13:15:47 +0000
Lines 14
Message-ID <mailman.75.1467119759.2358.python-list@python.org> (permalink)
References <079ff112-8f18-4a27-938f-12e4e55a4a5b@googlegroups.com> <CAGgTfkOkhy8HMd2w-hTHMb4K4vsJhAhoAju2y=+c87Fj=ciZRA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 5uFNnEUKBl6hf8TGWFVrlQnzkMpPQtdbYGvV4to4Wjzw==
Return-Path <michael.selik@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'preferable': 0.09; 'subject:while': 0.09; 'python': 0.10; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'variable.': 0.16; 'wrote:': 0.16; 'email addr:gmail.com&gt;': 0.18; 'to:2**1': 0.21; 'simpler': 0.22; 'code.': 0.23; 'second': 0.24; 'header:In-Reply- To:1': 0.24; 'not.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'looks': 0.29; 'url:wikipedia': 0.29; 'url:wiki': 0.30; 'code': 0.30; 'version,': 0.30; 'tue,': 0.34; 'received:google.com': 0.35; 'should': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'wanted': 0.37; 'someone': 0.38; 'why': 0.39; 'url:en': 0.39; 'to:addr:python.org': 0.40; 'better.': 0.66; 'elizabeth': 0.72
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Qg1eBE4UlD8aTwR8iLwuokVONyxwA1VYwIK9l7bbu2g=; b=hlpdnTT8ossLqZNfVbDUCCsfp4aOO2e40NAcbWwytAUu8sZ9MzIWMkU4JQ9o8RwtRH iuH5azGcpoe3fRyOpxyobmZIys5/nnXrcyscy4AHhQS7d9aboySXRFqSMdZ4wq1R9aVH NfExz/yL6wEla7gwOakwmTYVOMUTqIpkraPdbQKijTPzyKXOF5GZG2TlTFPO9Pnpd/2V nTKw86LXu1bKQobLokBW0x+TpMacV6azQ+kw8eqSBpRo53+hBHpdLANE4KuVwWAglOhe FL+X54TrIBx825S52G8r8t5b6q7Y0uCt34J7YWlYsDl3LQSovB9Dg/ecd7VH90tNAFtx JEjA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Qg1eBE4UlD8aTwR8iLwuokVONyxwA1VYwIK9l7bbu2g=; b=ksNhpMimyW3kgi36/4gDWqlEJDRs2m/bJQBhrth0MxZvfXdU3EDv7ICoNbF7boxwcr J1kO5jr68y1zgTrJGg36Hc2kD93xACk+779As2W1WpoKyfeju68Z/vLxDeqOL0onyDGz 8uVb66Arf3Y58ddtl4l3s5+Hb57EaF02lEKHGY2oKWe1hsUTA59c4n6pr7XEVwd78HqW 4itZ70YkNFykI+WOlt0OkR/4ofR1BfLspQgKDfoN/SOql4y8TowpV0YHt4rnXE27kSH7 Pv4B8d2YOISPMJMxuAcOTxELiPgoso8wJOiDRQp1AXaVixEtwpNoA1sFrWqoH0l++Rly jpGQ==
X-Gm-Message-State ALyK8tJ96VAVZYDoh4QLEHrJb5r2o17AAoO5NUp/IkbwUikLc9u80WYGbOCG3aH8+4aGLe1zUUcGCNQtU+A4Lw==
X-Received by 10.55.145.67 with SMTP id t64mr1743711qkd.96.1467119757034; Tue, 28 Jun 2016 06:15:57 -0700 (PDT)
In-Reply-To <079ff112-8f18-4a27-938f-12e4e55a4a5b@googlegroups.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.22
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAGgTfkOkhy8HMd2w-hTHMb4K4vsJhAhoAju2y=+c87Fj=ciZRA@mail.gmail.com>
X-Mailman-Original-References <079ff112-8f18-4a27-938f-12e4e55a4a5b@googlegroups.com>
Xref csiph.com comp.lang.python:110688

Show key headers only | View raw


On Tue, Jun 28, 2016 at 8:41 AM Elizabeth Weiss <cake240@gmail.com> wrote:

> I do not understand the second code. What is counter?
>

It looks like someone wanted to make a loop induction variable.
https://en.wikipedia.org/wiki/Induction_variable


> Why do we use this code if we can use the simpler for loop?
>

You should not. Use the first version, it's much better. Python for-loops
are preferable to while-loops.

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


Thread

Iteration, while loop, and for loop Elizabeth Weiss <cake240@gmail.com> - 2016-06-28 05:36 -0700
  Re: Iteration, while loop, and for loop Michael Selik <michael.selik@gmail.com> - 2016-06-28 13:15 +0000
    Re: Iteration, while loop, and for loop BartC <bc@freeuk.com> - 2016-06-28 14:29 +0100
      Re: Iteration, while loop, and for loop Michael Selik <michael.selik@gmail.com> - 2016-06-28 13:58 +0000
      Re: Iteration, while loop, and for loop Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-28 22:58 -0700
  Re: Iteration, while loop, and for loop BartC <bc@freeuk.com> - 2016-06-28 14:24 +0100
  RE: Iteration, while loop, and for loop "Joseph Lee" <joseph.lee22590@gmail.com> - 2016-06-28 06:26 -0700
  Re: Iteration, while loop, and for loop Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-28 16:42 +0300
  Re: Iteration, while loop, and for loop Michael Selik <michael.selik@gmail.com> - 2016-06-28 13:51 +0000
  Re: Iteration, while loop, and for loop Steven D'Aprano <steve@pearwood.info> - 2016-06-29 01:20 +1000
    Re: Iteration, while loop, and for loop Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-28 18:28 +0300
    Re: Iteration, while loop, and for loop Tim Chase <python.list@tim.thechases.com> - 2016-06-28 12:23 -0500
    Re: Iteration, while loop, and for loop Grant Edwards <grant.b.edwards@gmail.com> - 2016-06-28 17:58 +0000
    Re: Iteration, while loop, and for loop Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-29 09:29 -0600
      Re: Iteration, while loop, and for loop Steven D'Aprano <steve@pearwood.info> - 2016-06-30 09:59 +1000
        Re: Iteration, while loop, and for loop Tim Chase <python.list@tim.thechases.com> - 2016-06-30 05:44 -0500
        Re: Iteration, while loop, and for loop Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-30 07:04 -0600
        Re: Iteration, while loop, and for loop Ian Kelly <ian.g.kelly@gmail.com> - 2016-06-30 07:10 -0600
        Re: Iteration, while loop, and for loop jfong@ms4.hinet.net - 2016-06-30 19:12 -0700
  Re: Iteration, while loop, and for loop Veek M <vek.m1234@gmail.com> - 2016-10-27 14:35 +0530

csiph-web