Try Exclude and operators

Matt Athome via Tutor <[email protected]>
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
Python version
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32

Purpose
Give test score for input between 0.0 to 1.0
Use the try and exclude to throw up a message for invalid user input.

code gives the following error.
 score >= 0 and <= 1.0
                        ^^
SyntaxError: invalid syntax

# Score between 0.0 and 1.0
score = float(input("Enter Score: "))
try:
    score >= 0 and <= 1.0 
except:
    print("Enter a score between 0.0 and 1.0")
    quit() 
if score >= 0.9:
    print("A")
elif score >= 0.8:
    print("B")
elif score >= 0.7:
    print("C")
elif score >= 0.6:
    print("D")
elif score < 0.6:
    print("F")
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.