On Apr 14, 10:19 am, [EMAIL PROTECTED] wrote:
> Hi!
> I ran in problem with simple exercise. I'm trying to get program to
> return grade when given points but no matter what, I always get F.
>
> def grader():
>      print "Insert points: "
>      points = raw_input('> ')
>      int(points)
>
>      if points > 89 and points <= 100:
>          return "A"
>      elif points > 89 and points <= 89:
>          return "B"
>      elif points > 69 and points <= 79:
>          return "C"
>      elif points > 59 and points <= 69:
>          return "D"
>      else:
>          return "F"
>
> grade = grader()
> print grade

You have a typo in the first "elif": "points > 89 and points <= 89" is
never true, so you'll get an "F" instead of a "B".

BTW, Python lets you write things like "80 <= points < 90".

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to