[Tutor] bug in exam score conversion program

Kent Johnson kent37 at tds.net
Sat Oct 4 18:58:08 CEST 2008

On Sat, Oct 4, 2008 at 10:31 AM, Brian C. Lane <bcl at brianlane.com> wrote:

>    for g in grades:
>        if (score <= g[1]) and (score >= g[0]):
>            return g[2]

I think tuple unpacking makes code like this more readable:

for lower, upper, grade in grades:
  if lower <= score <= upper:
    return grade


More information about the Tutor mailing list