On Tue, Apr 03, 2018 at 01:00:59AM +0100, Alan Gauld via Tutor wrote:

> You need to use 'in' instead. That will check whether
> or not Grade is *one* of the values in the tuple.
> 
>     if Grade not in 'A','B','C','D','E','F':

Actually, that returns a tuple consisting of a flag plus five more 
strings:

py> 'A' in 'A','B','C', 'D', 'E', 'F'
(True, 'B','C', 'D', 'E', 'F')

We need to put round brackets (parentheses) around the scores:

    if Grade not in ('A','B','C','D','E','F'):


Don't be tempted to take a short-cut:

    # WRONG!
    if Grade not in 'ABCDEF':

as that would accepted grades like "CDEF" and "BC".



-- 
Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to