Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11386
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'counting': 0.09; '10000:': 0.16; 'abhishek': 0.16; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'head,': 0.16; 'wrote:': 0.16; 'meant': 0.17; 'subject:question': 0.18; 'once,': 0.18; 'stuff': 0.22; 'header:In-Reply-To:1': 0.22; 'loop,': 0.23; 'asked': 0.23; 'pm,': 0.24; 'variable': 0.24; 'aug': 0.24; 'do,': 0.25; 'code.': 0.26; 'problem': 0.28; 'looks': 0.29; 'message- id:@mail.gmail.com': 0.29; "won't": 0.29; 'print': 0.29; 'if,': 0.30; 'sun,': 0.30; '\xa0\xa0\xa0': 0.31; 'chris': 0.32; 'it.': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.33; 'skip:# 10': 0.34; 'here,': 0.35; 'supposed': 0.35; 'doing': 0.36; 'but': 0.37; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'your': 0.61; 'number.': 0.63; 'prime': 0.67; 'note:': 0.68; 'doing.': 0.73; 'defeat': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=ginvINpOApbzb7unoLFdrX4dB2GPjKduGQP8IyXwRdg=; b=AzTv0F61+WtCcP6EkXpLqatR+yXN6jzIiwyTszeFRSDKR/GKiIxAaDkud7AGKK+h9H 0GhlWc/AiQMMVX57WnTsJ8y6gzHZP9RDH0Lf6QqflIFly9EPZdoTGcQouZaMDeG33ihP i+RgX2T+JC5B126840kKcf4DIGGQfVn+rZpgA= |
| MIME-Version | 1.0 |
| In-Reply-To | <CAET16bwXNEEmjTt6Y7wzCjgsJVH_9p2Tpzvn9CvTtC+GKPf-ew@mail.gmail.com> |
| References | <CAET16bwXNEEmjTt6Y7wzCjgsJVH_9p2Tpzvn9CvTtC+GKPf-ew@mail.gmail.com> |
| Date | Sun, 14 Aug 2011 13:47:44 +0100 |
| Subject | Re: question |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2269.1313326067.1164.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313326067 news.xs4all.nl 23963 [2001:888:2000:d::a6]:38889 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11386 |
Show key headers only | View raw
On Sun, Aug 14, 2011 at 1:36 PM, Abhishek Jain <abhishekjain.cooldude.93@gmail.com> wrote: > ## this is to find the 1000th prime number > > number = 3 > while number < 10000: > ###initialize stuff > counter = 1 I think your main problem here, and you have several, is with this variable 'counter'. Have a really good think about what the counter is supposed to do, and ensure that it's really doing it. If, as I suspect, it's meant to be counting prime numbers such that you print the thousandth, then you want to set it once, outside the loop, and increment it only when you find a prime number. (Point to note: The first prime number is 2, not 3.) You asked for code. This looks like a homework assignment, so I won't actually do your work for you, for that would defeat the purpose. But think about every variable you use, what it ought to be doing, and what it's actually doing. Step through the program in your own head, and be sure you fully understand what it's doing. Chris Angelico
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: question Chris Angelico <rosuav@gmail.com> - 2011-08-14 13:47 +0100
csiph-web