Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45753
| From | Alister <alister.ware@ntlworld.com> |
|---|---|
| Subject | Re: Newbie question about evaluating raw_input() responses |
| Newsgroups | comp.lang.python |
| References | <534d7800-14c1-430b-85fb-dd703c2acc4d@googlegroups.com> <c8d5972d-9b11-4885-a68d-6ce1d0414718@googlegroups.com> |
| Message-ID | <IGbnt.31113$LC7.15822@fx06.am4> (permalink) |
| Organization | virginmedia.com |
| Date | 2013-05-22 22:31 +0000 |
On Tue, 21 May 2013 23:52:30 -0700, Kevin Xi wrote:
> On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote:
>> Hi,
>>
> 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.
>>
> So you may want to search the doc before you ask: http://docs.python.org
>>
>> 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.')
>
> You can either use `raw_input` to read data and convert it to right
> type, or use `input` to get an integer directly. Read this:
> http://docs.python.org/2/library/functions.html#raw_input
> http://docs.python.org/2/library/functions.html#input
>
>
Kevin
Please write out 1000 time (without using any form of loop)
"NEVER use input in python <3.0 it is EVIL"*
as Chris A point out it executes user input an can cause major damage
(reformatting the hard disk is not impossible!)
--
Quality Control, n.:
The process of testing one out of every 1,000 units coming off
a production line to make sure that at least one out of 100 works.
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