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