Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45711
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fabiosantosart@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.029 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'else:': 0.03; '"if': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '18:': 0.16; 'integer.': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'advance.': 0.19; 'user.': 0.19; 'code,': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'script': 0.25; '>': 0.26; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'anyone': 0.31; 'run': 0.32; 'url:python': 0.33; 'convert': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'starting': 0.37; 'expected': 0.38; 'ends': 0.38; 'obtain': 0.39; 'url:mail': 0.40; 'even': 0.60; 'results.': 0.60; 'numbers': 0.61; 'simple': 0.61; 'to:addr:gmail.com': 0.65; 'age': 0.80; 'age)': 0.84; '\xa0many': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/srpQM1VvImDDeMpuoAGS+/9yaHnxu32c89jblihUfk=; b=OomcjqKg1csC0zKCBzPL7nh+XJeoZ2cjtc4AaZ5mHmbcKaHNVIoRa1IPeQr7n5y/pH arDpKq8Veu19e+CS92R891QvqBBR2HeR69z4d8GVM1iUqU9oZNbCEW0xnfas+XbmpBZ7 AnHxwwnSXk1leAibgF0zkqFL305nUs7otYn0WdkzAkGKWNcUJbehFvrDQUq/NMpyBrxL xAMy6ZEQCq4bHpmYHCP04/lJmgs0ENXzncgCDfrR9orSpOqANBOMJTZvkS/nvp+jP09t Bptv/K8/PaCM6LTE0Pp0hxGzCvFRC4aA6/WZ4TdV8BiV+No6xQg2j3EF9gaU7i8BMkYg o0lA== |
| MIME-Version | 1.0 |
| X-Received | by 10.224.61.1 with SMTP id r1mr5751913qah.93.1369204519343; Tue, 21 May 2013 23:35:19 -0700 (PDT) |
| In-Reply-To | <534d7800-14c1-430b-85fb-dd703c2acc4d@googlegroups.com> |
| References | <534d7800-14c1-430b-85fb-dd703c2acc4d@googlegroups.com> |
| Date | Wed, 22 May 2013 07:35:18 +0100 |
| Subject | Re: Newbie question about evaluating raw_input() responses |
| From | Fábio Santos <fabiosantosart@gmail.com> |
| To | "C. N. Desrosiers" <cndesrosiers@gmail.com> |
| Content-Type | multipart/alternative; boundary=001a11c3f4d4003d8804dd48c533 |
| Cc | python-list@python.org |
| 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 | <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.1954.1369204522.3114.python-list@python.org> (permalink) |
| Lines | 59 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369204522 news.xs4all.nl 15973 [2001:888:2000:d::a6]:58192 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45711 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
You have to convert `age` to an integer. Use int() to do it. Then you can
compare it to other numbers and obtain the expected results.
On 22 May 2013 07:29, "C. N. Desrosiers" <cndesrosiers@gmail.com> wrote:
> Hi,
>
> I'm just starting out with Python and to practice I am trying to write a
> script that can have a simple conversation with the user.
>
> When I run the below code, it always ends up printing response to "if age
> > 18:" -- even if I enter a value below 18.
>
> Can anyone point me to what I am doing wrong? Many thanks in advance.
>
> age=raw_input('Enter your age: ')
> if age > 18:
> print ('Wow, %s. You can buy cigarettes.' % age)
> else:
> print ('You are a young grasshopper.')
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Newbie question about evaluating raw_input() responses "C. N. Desrosiers" <cndesrosiers@gmail.com> - 2013-05-21 23:23 -0700
Re: Newbie question about evaluating raw_input() responses Fábio Santos <fabiosantosart@gmail.com> - 2013-05-22 07:35 +0100
Re: Newbie question about evaluating raw_input() responses "C. N. Desrosiers" <cndesrosiers@gmail.com> - 2013-05-21 23:52 -0700
Re: Newbie question about evaluating raw_input() responses Kevin Xi <kevin.xgr@gmail.com> - 2013-05-21 23:52 -0700
Re: Newbie question about evaluating raw_input() responses Chris Angelico <rosuav@gmail.com> - 2013-05-22 17:19 +1000
Re: Newbie question about evaluating raw_input() responses Alister <alister.ware@ntlworld.com> - 2013-05-22 22:31 +0000
RE: Newbie question about evaluating raw_input() responses Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-23 01:55 +0300
Re: Newbie question about evaluating raw_input() responses Kevin Xi <kevin.xgr@gmail.com> - 2013-05-22 18:56 -0700
Re: Newbie question about evaluating raw_input() responses Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-23 04:47 +0000
Re: Newbie question about evaluating raw_input() responses Chris Angelico <rosuav@gmail.com> - 2013-05-23 16:04 +1000
Re: Newbie question about evaluating raw_input() responses Terry Jan Reedy <tjreedy@udel.edu> - 2013-05-23 03:11 -0400
Re: Newbie question about evaluating raw_input() responses Chris Angelico <rosuav@gmail.com> - 2013-05-23 17:20 +1000
Re: Newbie question about evaluating raw_input() responses Nobody <nobody@nowhere.com> - 2013-05-25 19:27 +0100
Re: Newbie question about evaluating raw_input() responses Chris Angelico <rosuav@gmail.com> - 2013-05-26 04:33 +1000
Re: Newbie question about evaluating raw_input() responses Fábio Santos <fabiosantosart@gmail.com> - 2013-05-25 23:11 +0100
Re: Newbie question about evaluating raw_input() responses Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-23 18:51 -0400
csiph-web