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" <cndesrosi...@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 >
-- http://mail.python.org/mailman/listinfo/python-list