Newbie question about evaluating raw_input() responses
C. N. Desrosiers
cndesrosiers at gmail.com
Wed May 22 02:52:41 EDT 2013
Muchas gracias!
On Wednesday, May 22, 2013 2:35:18 AM UTC-4, Fábio Santos wrote:
> 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" <cndesr... at 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
More information about the Python-list
mailing list