Simple integer comparison problem

Anton Vredegoor anton.vredegoor at gmail.com
Sat Apr 14 13:26:32 EDT 2007


Bart Willems wrote:

> I have a feeling that there's a Python-solution that is shorter yet 
> better readable, I just can't figure it out yet...

Shorter (and faster for big lists): Yes. More readable: I don't know, I 
guess that depends on ones familiarity with the procedure.

import bisect

def grader(score):
     c = bisect.bisect([60,70,80,90],score)
     return 'FDCBA'[c]

A.



More information about the Python-list mailing list