David try this: score = input("What is your exam score: (0-100)? ") print getGrade print getGrade(score)
Regards, Dragoshttp://scripts.mit.edu/~dionescu/pyworld/ ----- Original Message ---- From: David <[EMAIL PROTECTED]> To: Brian C. Lane <[EMAIL PROTECTED]> Cc: tutor@python.org Sent: Saturday, October 4, 2008 7:55:57 PM Subject: Re: [Tutor] bug in exam score conversion program When I run it from the idle it works perfect, but when I run it from a file I get none, why is that? >>> grades = [ (90,100,'A'), (80, 89,'B'), (70, 79,'C'), (60, 69,'D'), ( 0, 59,'F'), ] >>> score = 66 >>> def getGrade(score): """ Return a letter grade based on a score """ for g in grades: if (score <= g[1]) and (score >= g[0]): return g[2] >>> getGrade <function getGrade at 0x84ec80> >>> getGrade(score) 'D' >>> #!/usr/bin/python grades = [ (90,100,'A'), (80, 89,'B'), (70, 79,'C'), (60, 69,'D'), ( 0, 59,'F'), ] def getGrade(score): """ Return a letter grade based on a score """ for g in grades: if (score <= g[1]) and (score >= g[0]): return g[2] score = raw_input("What is your exam score: (0-100)? ") print getGrade print getGrade(score) What is your exam score: (0-100)? 66 <function getGrade at 0x2b4b2a310d70> None -- Have Fun, David A. Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor