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


Groups > comp.lang.python > #108582

Re: Average calculation Program *need help*

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Torrie <torriem@gmail.com>
Newsgroups comp.lang.python
Subject Re: Average calculation Program *need help*
Date Thu, 12 May 2016 23:29:47 -0600
Lines 33
Message-ID <mailman.625.1463117393.32212.python-list@python.org> (permalink)
References <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> <dab38f98-4ba3-4673-bfb3-e2aa676c9110@googlegroups.com> <57355EA6.50905@gmail.com> <mailman.621.1463115436.32212.python-list@python.org> <26884493-24d4-4d3d-b7d8-816f043b28b7@googlegroups.com> <5735664B.8000506@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de 6hWfrLW1U37XEJdmkxDBFwNqOUXBJg4mysTSLJGoXxoA==
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'yet.': 0.03; 'subject:help': 0.07; 'block.': 0.09; 'loop.': 0.09; 'statements': 0.09; 'example:': 0.10; 'python': 0.10; 'languages,': 0.15; 'accordingly': 0.16; 'fashion,': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'general.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'run.': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; 'tells': 0.18; 'programmer': 0.18; 'logical': 0.22; 'programming': 0.22; "python's": 0.23; "haven't": 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'forces': 0.29; 'if,': 0.29; 'indentation': 0.29; 'loop,': 0.29; 'screen.': 0.29; "i'm": 0.30; 'probably': 0.31; 'certain': 0.31; 'another': 0.32; 'screen': 0.32; 'statement': 0.32; 'problem': 0.33; 'adjust': 0.33; 'true.': 0.33; 'message-id:@gmail.com': 0.34; 'clear': 0.35; 'level': 0.35; 'should': 0.36; '(and': 0.36; 'basic': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:org': 0.37; 'things': 0.38; 'stuff': 0.38; 'sure': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'some': 0.40; 'him': 0.60; 'your': 0.60; 'close': 0.61; 'charset:windows-1252': 0.62; 'you.': 0.64; 'hours': 0.65; 'sit': 0.66; 'lol.': 0.72; 'sounds': 0.76; 'computers.': 0.84; 'subject: *': 0.84; "writer's": 0.84; 'subject:*': 0.93
X-Virus-Scanned amavisd-new at torriefamily.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
In-Reply-To <26884493-24d4-4d3d-b7d8-816f043b28b7@googlegroups.com>
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 <5735664B.8000506@gmail.com>
X-Mailman-Original-References <011a2f60-aafd-484f-8cb2-6017aaf1bb29@googlegroups.com> <dab38f98-4ba3-4673-bfb3-e2aa676c9110@googlegroups.com> <57355EA6.50905@gmail.com> <mailman.621.1463115436.32212.python-list@python.org> <26884493-24d4-4d3d-b7d8-816f043b28b7@googlegroups.com>
Xref csiph.com comp.lang.python:108582

Show key headers only | View raw


On 05/12/2016 11:03 PM, Jake Kobs wrote:
> Im not sure how to move it inside the for loop. I've been working on
> this small problem for like 4 hours lol.

I'm sorry it's so frustrating.  Sounds like you haven't got down some of
the most basic fundamentals yet.  In Python, things that should happen
one after another are placed at the same indent level on the screen.

For example:

if something:
    do_this()
    then_this()
    then_that()

Everything indented in from the start of the if statement is in a block
and only happens if the if statement condition is true.  If there're
statements at the same level as the if, then they happen *after* the if
and it's block.  In other words, indentation is what tells Python where
you want things to run.  If you want to move the while loop inside the
for loop, you have to adjust it's indentation accordingly (and the
indentation in it's own block).

This is a big gotcha for people unfamiliar with programming in Python,
and unfamiliar with programming in general.  In other languages, indents
don't have to be a certain way, as long as you have the write statements
to close off the loop.  However, Python's method forces you to think
like a programmer and to lay things out on the screen in a logical
fashion, like a writer's outline.

If you're still stuck, you will probably want to sit down with your
teacher and have him or her go over this with you.  This is important
basic stuff you need to have clear in your mind to program computers.

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


Thread

Average calculation Program *need help* kobsx4@gmail.com - 2016-05-12 08:47 -0700
  Re: Average calculation Program *need help* Rustom Mody <rustompmody@gmail.com> - 2016-05-12 09:01 -0700
  Re: Average calculation Program *need help* Igor Korot <ikorot01@gmail.com> - 2016-05-12 12:06 -0400
    Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-12 19:45 -0400
  Re: Average calculation Program *need help* "Martin A. Brown" <martin@linux-ip.net> - 2016-05-12 09:13 -0700
  Re: Average calculation Program *need help* MRAB <python@mrabarnett.plus.com> - 2016-05-12 17:14 +0100
  Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 21:22 -0700
    Re: Average calculation Program *need help* Ben Finney <ben+python@benfinney.id.au> - 2016-05-13 14:55 +1000
    Re: Average calculation Program *need help* Michael Torrie <torriem@gmail.com> - 2016-05-12 22:57 -0600
      Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 22:03 -0700
        Re: Average calculation Program *need help* Michael Torrie <torriem@gmail.com> - 2016-05-12 23:29 -0600
    Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-13 01:12 -0400
  Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-12 22:46 -0700
    Re: Average calculation Program *need help* Nick Sarbicki <nick.a.sarbicki@gmail.com> - 2016-05-13 07:10 +0000
      Re: Average calculation Program *need help* Jake Kobs <kobsx4@gmail.com> - 2016-05-13 08:38 -0700
        Re: Average calculation Program *need help* DFS <nospam@dfs.com> - 2016-05-13 12:17 -0400

csiph-web