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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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.