Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75833
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andrew.christianson@ipsos.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'read.': 0.03; 'elif': 0.05; 'tries': 0.07; 'meaningful': 0.09; '--------': 0.10; '>the': 0.16; 'guess.': 0.16; 'loop.': 0.16; 'looping': 0.16; 'received:exchangelabs.com': 0.16; 'received:prod.exchangelabs.com': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '<': 0.19; 'example': 0.22; 'aug': 0.22; 'putting': 0.22; 'to:name:python-list@python.org': 0.22; 'question': 0.24; '>': 0.26; 'asking': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; "doesn't": 0.30; 'statement': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'getting': 0.31; 'url:wiki': 0.31; 'indentation': 0.31; 'received:169.254': 0.32; 'supposed': 0.32; 'another': 0.32; 'url:python': 0.33; 'guess': 0.33; 'but': 0.35; 'skip:> 10': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:169': 0.37; 'email addr:python.org': 0.37; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'skip:& 20': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'space': 0.40; 'url:mail': 0.40; 'back': 0.62; 're:': 0.63; 'skip:n 10': 0.64; 'places': 0.64; 'email name:python-list': 0.65; 'charset:windows-1252': 0.65; 'effectively': 0.66; 'number:': 0.66; 'here': 0.66; 'exercise.': 0.84; 'guessed': 0.84; 'working,': 0.84 |
| From | Andrew Christianson <Andrew.Christianson@Ipsos.com> |
| To | Seymore4Head <Seymore4Head@Hotmail.invalid>, "python-list@python.org" <python-list@python.org> |
| Subject | RE: Wikibooks example doesn't work8 |
| Thread-Topic | Wikibooks example doesn't work8 |
| Thread-Index | AQHPsfGv0AE8WyzGq0K0nV1gS+qxWQ== |
| Date | Thu, 7 Aug 2014 03:43:00 +0000 |
| References | <r7s5u913pkc0ja59tko4ucravsliljkach@4ax.com> |
| In-Reply-To | <r7s5u913pkc0ja59tko4ucravsliljkach@4ax.com> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [12.0.87.57] |
| x-microsoft-antispam | BCL:0;PCL:0;RULEID: |
| x-forefront-prvs | 029651C7A1 |
| x-forefront-antispam-report | SFV:NSPM; SFS:(24454002)(479174003)(189002)(199002)(51704005)(85306004)(77096002)(63666004)(85852003)(106356001)(107046002)(4396001)(83072002)(74502001)(101416001)(95666004)(106116001)(105586002)(99396002)(74662001)(92726001)(19625215002)(2656002)(87936001)(15975445006)(107886001)(33646002)(19580395003)(76176999)(19580405001)(83322001)(19617315012)(92566001)(81542001)(79102001)(31966008)(64706001)(86362001)(54356999)(81342001)(46102001)(20776003)(50986999)(21056001)(16236675004)(15202345003)(77982001)(66066001)(76482001)(80022001); DIR:OUT; SFP:; SCL:1; SRVR:DB3PR01MB219; H:DB3PR01MB220.eurprd01.prod.exchangelabs.com; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; LANG:en; |
| MIME-Version | 1.0 |
| X-Microsoft-Antispam | BCL:0;PCL:0;RULEID: |
| X-OriginatorOrg | ipsos.com |
| X-MC-Unique | ZRovpmhWSrObVhJkpYtsfw-1 |
| Content-Type | multipart/alternative; boundary="_000_3l7tclbc0tp1hsu4r661t8tp1407382818739emailandroidcom_" |
| X-Mailman-Approved-At | Thu, 07 Aug 2014 07:04:36 +0200 |
| 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.12718.1407387878.18130.python-list@python.org> (permalink) |
| Lines | 156 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407387878 news.xs4all.nl 2867 [2001:888:2000:d::a6]:60007 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75833 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
The if statement in question isn't inside the while loop.
White space and indentation is meaningful in python, so putting the if count > 3 block at same indentation as the while statement effectively places it outside the loop.
Regards,
Drew
-------- Original message --------
From: Seymore4Head
Date:08/06/2014 20:32 (GMT-08:00)
To: python-list@python.org
Subject: Re: Wikibooks example doesn't work
On Wed, 06 Aug 2014 22:58:51 -0400, Seymore4Head
<Seymore4Head@Hotmail.invalid> wrote:
>number = 7
>guess = -1
>count = 0
>
>print("Guess the number!")
>while guess != number:
> guess = int(input("Is it... "))
> count = count + 1
> if guess == number:
> print("Hooray! You guessed it right!")
> elif guess < number:
> print("It's bigger...")
> elif guess > number:
> print("It's not so big.")
The part to here is supposed to be an example to allow the user to
guess at a number (7) with an infinite amount of tries.
This part was added as an exercise.
A counter is added to give 3 tries to guess the number.
It is supposed to stop after count gets to 3. It doesn't. It just
keeps looping back and asking for another guess.
>if count > 3:
> print("That must have been complicated.")
>else:
> print("Good job!")
>
>http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Decisions
>
>Why not?
>I think I know why it isn't working, but I don't know enough yet on
>how it should work.
>The If statement isn't getting read.
--
https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Wikibooks example doesn't work Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-06 22:58 -0400
Re: Wikibooks example doesn't work Chris Angelico <rosuav@gmail.com> - 2014-08-07 13:11 +1000
Re: Wikibooks example doesn't work John Gordon <gordon@panix.com> - 2014-08-07 03:18 +0000
Re: Wikibooks example doesn't work Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-06 23:25 -0400
Re: Wikibooks example doesn't work Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-07 13:43 +1000
Re: Wikibooks example doesn't work Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-06 23:48 -0400
Re: Wikibooks example doesn't work Larry Hudson <orgnut@yahoo.com> - 2014-08-06 21:59 -0700
Re: Wikibooks example doesn't work Ben Finney <ben+python@benfinney.id.au> - 2014-08-07 15:06 +1000
Re: Wikibooks example doesn't work Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-07 11:11 -0400
Re: Wikibooks example doesn't work alex23 <wuwei23@gmail.com> - 2014-08-07 14:09 +1000
RE: Wikibooks example doesn't work8 Andrew Christianson <Andrew.Christianson@Ipsos.com> - 2014-08-07 03:43 +0000
Re: Wikibooks example doesn't work Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-07 13:31 +1000
csiph-web