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


Groups > comp.lang.python > #62685

Re: Variables in a loop, Newby question

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <bgailer@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.030
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'python.': 0.02; 'variables': 0.07; 'subject:question': 0.10; 'python': 0.11; 'be:': 0.16; 'btw': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'python?': 0.22; 'header:User-Agent:1': 0.23; 'lets': 0.24; 'question': 0.24; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; "we'd": 0.29; 'am,': 0.29; 'to:no real name:2**1': 0.29; 'statement': 0.30; "i'm": 0.30; 'code': 0.31; '(on': 0.31; 'this.': 0.32; 'checking': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'var': 0.36; 'done': 0.36; 'message-id:@gmail.com': 0.38; 'mine': 0.38; 'to:addr :python-list': 0.38; 'little': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'matter': 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'to:addr:gmail.com': 0.65; 'results': 0.69; 'goal': 0.75
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=mKL/vxHFSUz6NB3Jt+iVspupPKW2fDea2gyvPXkKR54=; b=tMP8JfCmNxN3boUJJzc/XQpmRm9Zydrw6/xXyXKrPzeG0nXzZLfXeojj2N926ffMCG /mKCVvrW0aGRtTWUggezBOrLL5ELmQudYmINpkmNE5Uk7R0NXH7OSsrtnTx9iTwOkZM3 +BR/HnsfRTDyY2FnDgVQFoI916St3QzcWX2Ls8ybatxd+gqnpEz464S3hysAcSFa7axB PVxPoYje72kQg46uecJm0nMt132rpOIpaRMNsriEIxlDtsRFQoZ9cKEYA4KpEQlk+dJW iVP6o5RRQmBl4MmK0JhtlXQjLeEeYgChYfIdO9qzY0tEReeBmS1w09uZK4YP2xKUTDKC cYsg==
X-Received by 10.224.168.13 with SMTP id s13mr55346861qay.18.1387905979793; Tue, 24 Dec 2013 09:26:19 -0800 (PST)
Date Tue, 24 Dec 2013 12:26:09 -0500
From bob gailer <bgailer@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
To vanommen.robert@gmail.com, python-list@python.org
Subject Re: Variables in a loop, Newby question
References <9ad01eef-baf0-4018-833e-0b4dce4b9b85@googlegroups.com>
In-Reply-To <9ad01eef-baf0-4018-833e-0b4dce4b9b85@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.4600.1387905983.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387905983 news.xs4all.nl 2918 [2001:888:2000:d::a6]:57461
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62685

Show key headers only | View raw


On 12/24/2013 11:07 AM, vanommen.robert@gmail.com wrote:
> Hello, for the first time I'm trying te create a little Python program. (on a raspberri Pi)
>
> I don't understand the handling of variables in a loop with Python.
>
>
> Lets say i want something like this.
>
> x = 1
> while x <> 10
> 	var x = x
> 	x = x + 1
>
> The results must be:
>
> var1 = 1
> var2 = 2
>
> enz. until var9 = 9
>
> How do i program this in python?
The larger question is "why do you want to do that". It can be done but 
it is almost always a bad idea. Tell us what your goal is and we can 
tell you how we'd go about it.

BTW when checking a condition in a while statement it is better practice 
to say while x < 10. In the above case it does not matter but if you 
were incrementing x by 2 your code would be in an infinite loop, mine 
would still stop.

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


Thread

Variables in a loop, Newby question vanommen.robert@gmail.com - 2013-12-24 08:07 -0800
  Re: Variables in a loop, Newby question Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-24 11:20 -0500
  Re: Variables in a loop, Newby question "Tobias M." <tm@tobix.eu> - 2013-12-24 17:24 +0100
  Re: Variables in a loop, Newby question Peter Otten <__peter__@web.de> - 2013-12-24 17:29 +0100
  Re: Variables in a loop, Newby question bob gailer <bgailer@gmail.com> - 2013-12-24 12:26 -0500
  Re: Variables in a loop, Newby question vanommen.robert@gmail.com - 2013-12-24 09:54 -0800
    Re: Variables in a loop, Newby question Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-24 13:10 -0500
    Re: Variables in a loop, Newby question Dave Angel <davea@davea.name> - 2013-12-24 13:42 -0500
    Re: Variables in a loop, Newby question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-25 13:35 -0500
  Re: Variables in a loop, Newby question vanommen.robert@gmail.com - 2013-12-24 10:27 -0800
    Re: Variables in a loop, Newby question Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-25 02:54 +0000
      Re: Variables in a loop, Newby question Cameron Simpson <cs@zip.com.au> - 2013-12-25 16:42 +1100
        Re: Variables in a loop, Newby question Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-25 15:27 +0000
          Re: Variables in a loop, Newby question Cameron Simpson <cs@zip.com.au> - 2013-12-26 12:01 +1100
          Re: Variables in a loop, Newby question Chris Angelico <rosuav@gmail.com> - 2013-12-26 12:35 +1100
            Re: Variables in a loop, Newby question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-26 16:41 +1100
              Re: Variables in a loop, Newby question Dave Angel <davea@davea.name> - 2013-12-26 03:14 -0500
              Re: Variables in a loop, Newby question Chris Angelico <rosuav@gmail.com> - 2013-12-26 19:24 +1100
    Re: Variables in a loop, Newby question Peter Otten <__peter__@web.de> - 2013-12-25 15:52 +0100
    Re: Variables in a loop, Newby question Michael Torrie <torriem@gmail.com> - 2013-12-25 23:34 -0700
  Re: Variables in a loop, Newby question Larry Hudson <orgnut@yahoo.com> - 2013-12-25 00:13 -0800
  Re: Variables in a loop, Newby question vanommen.robert@gmail.com - 2013-12-27 00:53 -0800
    Re: Variables in a loop, Newby question Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-27 11:39 -0500

csiph-web